Skip to main content

TLS in Java for JSON DB API

Use TLS in Java for JSON DB API


Use TLS in Java for JSON DB API

This document shows how to configure TLS in the FairCom JSON DB API tutorial. The source code is in


The tutorial can be run without modification, but will not be secure.  This document describes how to load a certificate from the file system at runtime which will enable secure TLS communications.

  1. Copy the CA certificate to the machine running the tutorial, and note the directory it is saved to.

  2. Locate the ServerConnection serverConnection = new ServerConnection() code block in the source code.

  3. Change the endpoint to a secure endpoint:


  4. Between .endpoint and .configure, designate the location of the CA certificate file you saved:

    .caCertificatePath( "/path/to/my/ca.crt" )

    The final code block looks like this:

    ServerConnection serverConnection = new ServerConnection()
       .endpoint( "" )
       .caCertificatePath( "/path/to/my/ca.crt" )
  5. Run the tutorial.


  • The CA certificate must sign the server certificate.  A self-signed certificate will not work.

  • The Java client library for the FairCom JSON Action APIs provides additional methods to configure a secure connection, such as using a Java keystore or trustManagers.