Errors when using PostgreSQL with self-signed certificates

If you are using PostgreSQL with SSL with self-signed certificates, you might see an error with the JDBC connection to the database.

Symptoms

You might see the following error:
An SQL error occured while creating the JDBC connection to the database
org.postgresql.util.PSQLException: Loading the SSL root certificate /shared/resources/cert-trusted/tls.crt into a TrustManager failed.
at org.postgresql.ssl.LibPQFactory.<init>(LibPQFactory.java:159)

Causes

The certificate is not recognized by the JDBC driver.

Resolving the problem

You must remove -text when you run the command to generate the self-signed certification.

For example, remove -text from the following command:
openssl req -new -text -passout pass:<passw0rd> -subj /CN=<server_address> -out server.req -keyout privkey.pem