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
// 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
}