Install the TSB with Docker
This page is only relevant if you want to use an on-premise TSB. If you use the TSB from the Securosys Cloud, you can skip this page.
This guide walks you through setting up the REST API using Docker and Docker Compose. It assumes that the following prerequisites are already installed and configured:
What This Guide Covers
This step-by-step guide will help you set up the REST API in a development environment using Docker:
- Download Configuration Files
- Configure Docker Compose
- Configure the REST API
- Start and Test the Application
Step 1: Download configuration files
Head to the Downloads page to get instructions on how to get the software and credentials.
Step 2: Configure Docker Compose
Unzip the configuration-files and open the docker-compose.yml file.
nano docker-compose.yml
Edit the file depending on your preferred database:
- MySQL / MariaDB
- PostgreSQL
Select the PostgreSQL container image:
securosys_sql:
image: mariadb:11.8
#image: mysql:8.0 # uncomment for Windows (Docker Desktop)
Define the volume that is used to persist data across container restarts:
volumes:
- securosys_sql_data:/var/lib/mysql
Define the database users and passwords:
environment:
# Configuration for MySQL / MariaDB
- MYSQL_USER=replace-me_db-username # REPLACE with your credentials
- MYSQL_PASSWORD=replace-me_db-password # REPLACE with your credentials, ${MARIADB_PASSWORD} # Use environment variable for password security
- MYSQL_DATABASE=securosys
- MYSQL_PORT=3306
- MYSQL_ROOT_PASSWORD=replace-me_db-root-password # REPLACE with your credentials
- MYSQL_LOWER_CASE_TABLE_NAMES=0
Select the PostgreSQL container image:
securosys_sql:
image: bitnami/postgresql:latest
Define the volume that is used to persist data across container restarts:
volumes:
- securosys_sql_data:/bitnami/postgresql
Define the database users and passwords:
environment:
- POSTGRESQL_USERNAME=replace-me_db-username # REPLACE with your credentials
- POSTGRESQL_PASSWORD=replace-me_db-password # REPLACE with your credentials, ${POSTGRES_PASSWORD} # Use environment variable for password security
- POSTGRESQL_DATABASE=securosys
- POSTGRESQL_MAX_CONNECTIONS=200
##- POSTGRESQL_REPLICATION_MODE=master
##- POSTGRESQL_REPLICATION_USER=replicator
##- POSTGRESQL_REPLICATION_PASSWORD=xxxx
##- POSTGRESQL_ENABLE_TLS=yes
##- POSTGRESQL_TLS_CERT_FILE=/opt/bitnami/postgresql/certs/server.crt
##- POSTGRESQL_TLS_KEY_FILE=/opt/bitnami/postgresql/certs/server.key
- Set passwords without special characters and 30-bytes long.
- It is strongly recommended to define all database passwords before starting the first container. Changing them later may lead to connection issues.
- Consider adding a
restart: alwayspolicy underservices.securosys_sqlindocker-compose.ymlto ensure the SQL server automatically restarts on failure or host reboot.
Step 3: Configure the REST API
Open the application configuration file:
nano config-files/application-local.yml
Configure the Database Connection
Configure the TSB with the username and password for the database (that you defined above in your docker-compose.yml).
Also define the URL under which the TSB can reach the database.
- MySQL / MariaDB
- PostgreSQL
spring:
datasource:
url: jdbc:mariadb://securosys_sql:3306/securosys?allowPublicKeyRetrieval=true&sslMode=false
#url: jdbc:mariadb://securosys_sql:3306/securosys?sslMode=verify-ca&trustStore=/etc/app/config/truststore.jks&trustStorePassword=change-it
username: replace-me_db-username # REPLACE according to the `MYSQL_USER` in the docker-compose.yml file
password: replace-me_db-password # REPLACE according to the `MYSQL_PASSWORD` in the docker-compose.yml file
spring:
datasource:
url: jdbc:postgresql://securosys_psql:5432/securosys?allowPublicKeyRetrieval=true&sslMode=false
username: replace-me_db-username # REPLACE according to the `POSTGRES_USER` in the docker-compose.yml file
password: replace-me_db-password # REPLACE according to the `POSTGRES_PASSWORD` in the docker-compose.yml file
Configure the HSM Connection
Configure the connectivity details to specify where the TSB can reach the HSM and which HSM partition the TSB should use.
For details, see the Connectivity Details page. You should have received these values from your HSM administrator.
The only exception is the encryptionPassword, which you need to generate yourself.
A randomly generated, 32-character, alphanumeric value is recommended.
This value is used to encrypt the HSM User Secret before storing it in the database.
hsm:
host: 'ch01-api.cloudshsm.com,ch02-api.cloudshsm.com'
port: '2300'
user: replace-me_hsm-username
setupPassword: replace-me_hsm-setupPassword
encryptionPassword: replace-me_db-encryptionPassword
To enable load balancing, the hsm.host setting accepts the following format:
- Multiple hosts separated by commas:
The TSB will randomly select one host, falling back to the others if one fails.
For example:
hsm.host: 'grimsel.securosys.ch,nufenen.securosys.ch'. - Multiple hosts separated by semicolons:
The TSB will always choose the first record, falling back to the others if the first one fails.
For example:
hsm.host: 'grimsel.securosys.ch;nufenen.securosys.ch'.
Step 4: Start the Application
Log in to the container registry:
docker login securosys.jfrog.io -u robot.reader.tsb
You will be prompted for a password. You can obtain the password via the Downloads page.
Start the application:
docker compose up --detach
The container should start up.
Open the (Swagger) to interact with the REST API in your browser: http://localhost:8080/swagger-ui/index.html
Test with CURL
curl http://localhost:8080/v1/licenseInfo
Response:
{"clientFlags":["IMPORT","EXPORT","EXTRACT","KEY_AUTH","REST_API","TSB_ENGINE","EXTERNAL_STORAGE","DESTROY_OBJECTS","EXPORT_LOGS","EXTENDED_KEY_ATTRIBUTES","BTC","ETH","RIPPLE","IOTA","ROOT_KEY_STORE","TIMESTAMP_SERVICE","USEABLE_OBJECTS","CARDANO","PERSISTENT_EXTERNAL_OBJ","KYBER","DILITHIUM","SPHINCSPLUS","LMS","XMSS"]}
Listing Keys:
curl -v http://localhost:8080/v1/key
Response:
['attestation-key', 'timestamp-key']
This guide outlines a default setup of the REST API without HTTPS and without API authentication.
It is intended for development and testing purposes only and must not be used in production environments.
To harden the application, follow the post-installation guide.
What's next?
- Finish the production-grade setup:
- Configure HTTPS
- Configure Database TLS
- Setup API Authentication
- Create a Key and use it to encrypt and decrypt a payload