---
title: "Client API: Setting up Authentication and Authorization"
url: "https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization"
version: "6.2"
language: "java"
---

# Client API: Setting up Authentication and Authorization

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.md), [Node.js](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.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."

Authentication and authorization is based on [client X.509 certificates](https://docs.ravendb.net/6.2/server/security/authorization/security-clearance-and-permissions.md).

The `certificate` property allows you to pass a certificate which will be used by the RavenDB client to connect to a server.

> **Note**
>
> If your RavenDB instance is running on 'https', then your application has to use a client certificate in order to be able to access the server. You can find more information [here](https://docs.ravendb.net/6.2/server/security/overview.md).

## Example

```java
// load certificate
// pem file should contain both public and private key
KeyStore clientStore = CertificateUtils.createKeystore("c:\\ravendb\\app.client.certificate.pem");

try (DocumentStore store = new DocumentStore())  {
  store.setCertificate(clientStore);
  store.setDatabase("Northwind");
  store.setUrls(new String[]{ "https://my_secured_raven" });

  store.initialize();

  // do your work here
}
```

## See also

- [Installation : Setup Wizard Walkthrough](https://docs.ravendb.net/6.2/start/installation/setup-wizard/overview.md)
- [What is a Document Store](https://docs.ravendb.net/6.2/client-api/what-is-a-document-store.java.md)
- [Creating a Document Store](https://docs.ravendb.net/6.2/client-api/creating-document-store.java.md)
- [Setting up Default Database](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.java.md)
- [Security Overview](https://docs.ravendb.net/6.2/server/security/overview.md)
- [Security Clearance &amp; Permissions](https://docs.ravendb.net/6.2/server/security/authorization/security-clearance-and-permissions.md)
- [Client Certificiate Usage](https://docs.ravendb.net/6.2/server/security/authentication/client-certificate-usage.md)
- [Certificate Management](https://docs.ravendb.net/6.2/server/security/authentication/certificate-management.md)
