Search code examples
postgresqlssldatagrip

How to setup DataGrip connect Cloud SQL with SSL mode through Tunnel using DataGrip


I am a newbie for Cloud SQL and Cloud Security. So now I already use Cloud SQL and connect to the database with Compute Engine. I use it as a proxy server and use for remote connect from my local machine.

And then I need to use SSL connection try to create new client certificates and it was OK if I connect from my proxy server.

But not work when I try to connect from the local machine using DataGrip. I got an error message.

Connection to postgres@database-server failed. [08006] Could not open SSL root certificate file /home/user/.postgresql/root.crt.


Solution

  • This is caused by a change in the Postgres JDBC driver after version 42.2.2. Subsequent versions treat ssl=true to also be sslmode=verify-ca while also introducing a change that causes the default SSLFactory to not recognize the JRE cacerts.

    To resolve this, either revert to driver 42.2.2 or set the sslfactory to org.postgresql.ssl.DefaultJavaSSLFactory

    There is also a GitHub issue https://github.com/pgjdbc/pgjdbc/issues/1307