pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: Shalaka1197 (@Shalaka1197) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] issue #3349: SSL connection is not established
Date: Fri, 30 Aug 2024 06:27:44 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

@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();

	}
`



view thread (31+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3349: SSL connection is not established
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox