---
title: "Operations: Server: How to Generate a Client Certificate"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/create-client-certificate"
version: "6.2"
language: "csharp"
---

# Operations: Server: How to Generate a Client Certificate

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/create-client-certificate.java.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/create-client-certificate.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - You can generate a client certificate using **CreateClientCertificateOperation**.
>
> - Learn the rationale needed to properly define client certificates in [The RavenDB Security Authorization Approach](https://docs.ravendb.net/6.2/server/security/authentication/certificate-management.md#the-ravendb-security-authorization-approach)

## Syntax

```csharp
public CreateClientCertificateOperation(string name, 
  Dictionary<string, DatabaseAccess> permissions, 
  SecurityClearance clearance, 
  string password = null)
```

```csharp
// The role assigned to the certificate:
public enum SecurityClearance
{
  ClusterAdmin,
  ClusterNode,
  Operator,
  ValidUser
}
```

```csharp
// The access level for a 'ValidUser' security clearance:
public enum DatabaseAccess
{
  Read,
  ReadWrite,
  Admin
}
```

| Parameters | | |
| - | - | - |
| **name** | string | Name of a certificate |
| **permissions** | Dictionary\<string, DatabaseAccess> | Dictionary mapping databases to access level |
| **clearance** | SecurityClearance | Access level |
| **password** | string | Optional certificate password, default: no password |

| Return Value | |
| - | - |
| **RawData** | client certificate raw data |

## Example I

```csharp
// With the security clearance set to Cluster Administrator or Operator,
// the user of this certificate will have access to all databases
CreateClientCertificateOperation operation = 
  new CreateClientCertificateOperation(
      "admin", null, SecurityClearance.Operator);
CertificateRawData certificateRawData = 
  store.Maintenance.Server.Send(operation);
byte[] cert = certificateRawData.RawData;
```

## Example II

```csharp
// When the security clearance is ValidUser, you must specify an access level for each database
CreateClientCertificateOperation operation = 
  new CreateClientCertificateOperation(
      "user1", new Dictionary<string, DatabaseAccess>
{
  { "Northwind", DatabaseAccess.Admin }
}, SecurityClearance.ValidUser, "myPassword");
CertificateRawData certificateRawData = 
  store.Maintenance.Server.Send(operation);
byte[] cert = certificateRawData.RawData;
```

## See also

- [How to delete certificate?](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/delete-certificate.md)
- [How to put client certificate?](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/put-client-certificate.md)
- [Certificates Management](https://docs.ravendb.net/6.2/server/security/authentication/certificate-management.md#enabling-communication-between-servers:-importing-and-exporting-certificates)
- [Client Certificate Usage](https://docs.ravendb.net/6.2/server/security/authentication/client-certificate-usage.md)
