Using Certificate Authentication (Without a Password)

In order to use certificate authentication (without a password), follow the below steps:

  1. Convert the client certificate in DER format.
$ openssl x509 –in postgresql.crt -out postgresql.crt.der -outform
der
  1. Convert the client key in DER format.
$ openssl pkcs8 -topk8 -outform DER -in postgresql.key -out
postgresql.key.pk8 –nocrypt
  1. Copy client files (postgresql.crt.der, postgresql.key.pk8) and root certificate to the client machine and use following properties in your java program to test it:
String url = "jdbc:edb://snvm001:5444/edbstore";
     Properties props = new Properties();
     props.setProperty("user","enterprisedb");
     props.setProperty("ssl","true");
     props.setProperty("sslmode","verify-full");
     props.setProperty("sslcert","postgresql.crt.der");
     props.setProperty("sslkey","postgresql.key.pk8");
     props.setProperty("sslrootcert","root.crt");
  1. Compile the Java program and test it.
$ java -Djavax.net.ssl.trustStore=mystore -classpath
.:./edb-jdbc18.jar pg_ssl public