'How can I specify the SSL certificates on classpath when connecting to CloudSQL for PostgreSQL via JDBC?
I'm developing an application that will run on Google Kubernetes Engine, and I need to connect to a CloudSQL database (PostgreSQL) via JDBC. The problem is that this specific database has SSL/TLS enabled.
The JDBC driver for PostgreSQL supports certificates but only via absolute file paths. My certificates are located in src/main/resources, so absolute paths are not really an option. The default solution in PostgreSQL seems to be to use a dedicated socket factory that is capable of loading the certificate files from the classpath. However, since I need to connect to CloudSQL, I need to use the Socket Factory provided by Google. I tried to figure out if and how the Socket Factory implementation from google supports certificates and how to load them, but I couldn't find any documentation on that.
TL;DR:
- CloudSQL for PostgreSQL with SSL/TLS
- Certificates are on classpath
- What's the JDBC URL, in particular the SSL/TLS config part?
Solution 1:[1]
If you're using the Cloud SQL Socket Factory, you won't need to provide certificates.
One of the major appeals of the socket factory is that it handles all the TLS tunneling for you using ephemeral certificates.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | enocom |
