PostgreSQL TLS

This chapter describes how to configure TLS-secured connections from PAS-X MES to a PostgreSQL database.

Overview

PAS-X MES connects to PostgreSQL as a TLS client. Trusted certificate material is supplied in a Kubernetes Secret referenced from Instance configuration. The deployment injects that material into the MES service’s truststore and the JDBC client uses that trust material when connecting to the database.

For the structure of the Secret, refer to Kubernetes TLS Secrets Guidelines and the certificate management documentation referenced there.

Instance configuration

In Instance configuration, configure the following:

  • Database certificate Secret — Reference the Kubernetes Secret that contains the trusted certificate material for TLS to PostgreSQL (see Database Certificate Secret Name).

  • Database connection URL — Set the JDBC URL to include the TLS-related query parameters described in Connection string for TLS.

Verification tests

Verification tests take their database connectivity settings from MES Applications configuration. Configure these values to match the configurations defined in the Instance configuration.

If one or more settings drift from Instance configuration, verification tests may fail, or return an invalid result.

Connection string for TLS

The Instance JDBC URL and the URL used for verification tests must both follow the same rules for TLS query parameters. See Database URL for where the Instance value is defined in the schema.

To use TLS to PostgreSQL with PAS-X MES, reference the database certificate Secret in Instance configuration so the deployment injects trust material, and add the TLS query parameters on the JDBC URL (see the table below). Those parameters control how the driver uses TLS and how strictly the server is validated.

The JDBC URL can include query parameters after ?. Additional parameters are appended with & between name=value pairs.

The parameter summary below is excerpted from the official PostgreSQL JDBC driver documentation. For more information, see Initializing the Driver — connection parameters and Using SSL.

TLS query parameters

Parameter Purpose

ssl

When set to true, the driver connects using TLS. The server must support TLS.

sslfactory

Class name used as the SSLSocketFactory when establishing TLS.
For PAS-X MES, use org.postgresql.ssl.DefaultJavaSSLFactory.

sslmode

Controls validation and encryption. Possible values (see Using SSL):

  • disable — Do not use TLS.

  • allow — Use TLS if the server requires it; encryption may be used.

  • prefer — Use TLS if the server supports it; encryption may be used.

  • require — Require TLS; data encrypted.

  • verify-ca — Require TLS; data encrypted and server certificate chain verified.

  • verify-full — Require TLS; data encrypted, server certificate verified and host name matches the certificate.

Example of a connection string for a PostgreSQL TLS database
jdbc:postgresql://<database-host>:<port>/<database-name>?ssl=true&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory&sslmode=verify-full