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
<faircom>\drivers\java.json.db\tutorials\src\main\java\org\example\JsonActionExample.java
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.
Create a CA certificate.
Ensure you have a server certificate that is signed by the CA certificate.
Configure the FairCom server to use that server certificate.
Copy the CA certificate to the machine running the tutorial, and note the directory it is saved to.
Locate the
ServerConnection serverConnection = new ServerConnection()
code block in the source code.Change the endpoint to a secure endpoint:
endpoint: https://127.0.0.1:8443/api
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( "https://127.0.0.1:8443/api" ) .caCertificatePath( "/path/to/my/ca.crt" ) .configure();
Run the tutorial.
Note
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.