You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Client API: Setting up Authentication and Authorization

Authentication and authorization is based on client X.509 certificates.

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.

Example

// load certificate
KeyStore clientStore = KeyStore.getInstance("PKCS12");
clientStore.load(new FileInputStream("c:\\ravendb\\client-cert.pfx"), "passwordToPfx".toCharArray());

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
}