Specify ssl in context.xml

Hello, I am trying to put ssl=true for a postgres database connection in the context.xml.
it seem that :
url=“jdbc:postgresql://myshost:5432/mydatabse?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory” don’t work.
Thanks!!

Hello,

Could you please provide more details of your environment?

On my local test environment, I have configured Postgres server to use SSL, and everything works well: the server is available only with ssl=true in the “Connection params”. My configuration:

  1. I have generated a self-signed certificate as described in the Postgres documentation.

  2. The postgres.conf has the following contents.


ssl = on
ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers

ssl_cert_file = 'server.crt'	
ssl_key_file = 'server.key'	
  1. Also, the pg_hba.conf is configured to accept only SSL connections:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 connections:
hostssl    all             all             all           md5

Try to press “Test connection” in Studio. Is the connection successful with the specified params?

testConnection

The context.xml generated by Studio is as follows. See the URL. Try to type “& a m p ;” instead of “&”.


 <Resource driverClassName="org.postgresql.Driver"
              maxIdle="2"
              maxTotal="20"
              maxWaitMillis="5000"
              name="jdbc/CubaDS"
              password="postgres"
              type="javax.sql.DataSource"
              url="jdbc:postgresql://localhost/testlog?ssl=true&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory"
              username="postgres"/>