---
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: "nodejs"
---

# Operations: Server: How to Generate a Client Certificate

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/create-client-certificate.md), [Java](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/create-client-certificate.java.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)

## Usage

```javascript
const cert1 = await store.maintenance.server.send(
  new CreateClientCertificateOperation([name], [permissions], [clearance], [password]));
```

`SecurityClearance` options:

- `UnauthenticatedClients`
- `ClusterAdmin`
- `ClusterNode`
- `Operator`
- `ValidUser`

`DatabaseAccess ` options:

- `ReadWrite`
- `Admin`

| Parameters | | |
| - | - | - |
| **name** | string | Name of a certificate |
| **permissions** | Record\<string, DatabaseAccess> | Record 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

```javascript
// With user role set to Cluster Administrator or Operator the user of this certificate
// is going to have access to all databases
const clientCertificateOperation = await store.maintenance.server.send(
  new CreateClientCertificateOperation("admin", {}, "Operator"));
const certificateRawData = clientCertificateOperation.rawData;
```

## Example II

```javascript
// when security clearance is ValidUser, you need to specify per database permissions

const clearance = {
  [store.database]: "ReadWrite"
};
  }

t clientCertificateOperation = await store.maintenance.server.send(
new CreateClientCertificateOperation("user1", clearance, "ValidUser", "myPassword"));
t certificateRawData = clientCertificateOperation.rawData;
```

## See also

- [How to delete certificate?](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/delete-certificate.nodejs.md)
- [How to put client certificate?](https://docs.ravendb.net/6.2/client-api/operations/server-wide/certificates/put-client-certificate.nodejs.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)
