Search code examples
postgresqljdbc

postgres jdbc connection string with ssl certficate ( without keystore)


We want to connect the PostgreSQL db through jdbc using the self signed certificate. Keystore option is available but i want to pass the certificate though my jdbc command line . is there any option available for the same


Solution

  • According to the documentation, the URL will look somewhat like this:

    jdbc:postgresql://host:port/database?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&sslcert=/path/to/cert&sslkey=/path/to/key

    This assumes that the client doesn't need to verify the server's certificate, but the server will verify the client's certificate.