Jigar Naik
Jigar Naik

Reputation: 1994

Spring Boot Connecting database using SSL Certificate

I need to connect to postgresql using SSL Certificate from spring boot application. I have got the certificate and currently i am connecting to db using username and password which i have provided in application.yml file.

Can someone point me to the right tutorial? I could not find anything relevant for spring boot ssl database connection.

Upvotes: 4

Views: 6537

Answers (1)

Shailesh Chandra
Shailesh Chandra

Reputation: 2340

you need to append below in URL

&sslmode=verify-full&sslrootcert=/path/to/pemfile

Your URL will look something like

jdbc:postgresql://server:5432/databaseName?currentSchema=dbschema
    &sslmode=verify-full&sslrootcert=/home/certificates/mycert.pem

you can refer below URLs

https://jdbc.postgresql.org/documentation/head/connect.html#ssl

https://docs.amazonaws.cn/en_us/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL

Upvotes: 6

Related Questions