I am trying to configure an SSL connection between PostgreSQL and AWS Lambda. The problem is passing the AWS certificate PEM file to pgjdbc.
I added the PEM file to my resources folder and tried to get it's location with:
Thread.currentThread().getContextClassLoader().getResource("rds-combined-ca-bundle.pem").toString();
And it returns:
file:/var/task/rds-combined-ca-bundle.pem
But if I pass that as the sslrootcert
property, I get an exception:
org.postgresql.util.PSQLException: Could not open SSL root certificate file file:/var/task/rds-combined-ca-bundle.pem.
I then decided to run a code that prints all directories and files names from my Lambda, staring with the current folder, and I get the rds-combined-ca-bundle.pem
file at the current directory.
What's the correct way to get a PEM file from my resources and pass it to pgjdbc then?