Looking for Cloud Services or Professional Support? Check restheart.com

Edit Page

Configure TLS


This section provides instructions on how to enable Transport Layer Security so that requests can be served over the HTTPS protocol.

HTTP is not secure: credentials can be sniffed by a man-in-the-middle attack. It is paramount to use HTTPS
This section is about securing HTTP requests between Clients and RESTHeart. Read Secure connection to MongoDB for more information on how to secure the connection between RESTHeart and MongoDB.

The HTTPS listener

There are many ways of enabling HTTS; for instance you can setup a web server such as nginx as a reverse proxy in front of RESTHeart or you may rely on cloud services that provides load balancers that manages SSL for you (such are Amazon WS or Google Cloud).

In any case, restheart is able to expose directly the HTTS protocol and this is done configuring the https listener. This is the suggested configuration for small systems.

The following configuration file except shows the involved options:

    enabled: true
    port: 4443
    keystore-path: /path/to/keystore/file
    keystore-password: secret
    certificate-password: secret


$ http -d https://raw.githubusercontent.com/SoftInstigate/restheart/master/core/bin/generate-certauthority-and-keystore.sh # download the script generate-certauthority-and-keystore.sh
$ ./generate-certauthority-and-keystore.sh -d localhost -a /tmp -p secret # generate a test keystore and certificate authority
$ RHO='/https-listener->{ "enabled": true, "host": "localhost", "port": 4443, "keystore-path": "/tmp/localhost.jks", "keystore-password": "secret", "certificate-password": "secret" }' java -jar restheart.jar # run RESTHeart with TLS enabled
$ http -b --verify /tmp/devCA.pem https://restheart.local:4443/ping # execute a test TLS request
Greetings from RESTHeart!

To enable https configure the https listener using the following options:

  1. /https-listener/enabled true to enable it

  2. /https-listener/host the ip where to bind the listener

  3. /https-listener/port the port where to bind the listener

  4. /https-listener/keystore-path the path of the keystore

  5. /https-listener/keystore-password the password of the keystore

  6. /https-listener/certificate-password the password of the certificate

A SSL certificate must configured in order to enable the https listener.

Configure the SSL certificate

The SSL certificate must be added to the java keystore set by the keystore-file configuration property.

Two scripts are available to help configuring the keystore.


This is useful for testing purposes. It generates a CA and uses it to issue a SSL certificate, finally generating the keystore file.

Download the script from generate-certauthority-and-keystore.sh

After having generated the keystore file and configured RESTHeart to use it, you need to install the CA root certificate into your OS.

For example, in OSX:

  1. Open up Keychain Access application by searching it on Spotlight

  2. Select File > Import Items. Navigate to CA root certificate file generated by the script. Select System as "Destination Keychain".

  3. Right click on the certificate in Keychain Access and select Get Info

    • Expand the Trust section

    • Under When using this certificate select Always Trust.


Let’s Encrypt is a popular and nonprofit Certificate Authority providing free TLS certificates.

This script generates the java keystore from Let’s Encrypt certificate archive.

Download the script from convert-letsencrypt-java-keystore.sh