Message-ID: From: "Shalaka1197 (@Shalaka1197)" To: "pgjdbc/pgjdbc" Date: Fri, 30 Aug 2024 06:27:44 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3349: SSL connection is not established In-Reply-To: References: List-Id: X-GitHub-Author-Login: Shalaka1197 X-GitHub-Comment-Id: 2320206340 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2024-08-30T06:28:13Z X-GitHub-Issue: 3349 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3349#issuecomment-2320206340 Content-Type: text/plain; charset=utf-8 @davecramer When you are creating root.crt and server.crt file , try to create it with 0 days validity. for example command : ` openssl req -new -x509 -days 0 -nodes -text -out server.crt -keyout server.key -subj "/CN=localhost" ` and put both the certificates in postgres server. Below is sample code for replicating the issue. ssl: true sslmode:verify-ca sslrootcert: resources/server.crt public class ConnectDB { private final String url = "jdbc:postgresql://abcd:5432/postgres?" + "sslmode=verify-ca&sslrootcert=resources/server.crt"; private final String user = "postgres"; private final String password = "abcd"; public Connection connect() { Connection conn = null; try { conn = DriverManager.getConnection(url, user, password); System.out.println("Connected to the PostgreSQL server successfully."); } catch (SQLException e) { System.out.println(e.getMessage()); } return conn; } public static void main(String[] args) { ConnectDB db = new ConnectDB(); db.connect(); } `