我正在尝试使用 Java(启用 SSL)连接到 IBM Cloud PostgreSQL DB。但是在建立连接时,我收到以下错误 -
[7/31/19 10:48:46:952 UTC] 0000007a id= R org.postgresql.util.PSQLException: SSL error: Received fatal alert: handshake_failure
[7/31/19 10:48:46:953 UTC] 0000007a id= R at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:42)
[7/31/19 10:48:46:953 UTC] 0000007a id= R at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:441)
[7/31/19 10:48:46:953 UTC] 0000007a id= R at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
[7/31/19 10:48:46:953 UTC] 0000007a id= R at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
[7/31/19 10:48:46:954 UTC] 0000007a id= R at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
[7/31/19 10:48:46:954 UTC] 0000007a id= R at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
[7/31/19 10:48:46:954 UTC] 0000007a id= R at org.postgresql.Driver.makeConnection(Driver.java:458)
[7/31/19 10:48:46:954 UTC] 0000007a id= R at org.postgresql.Driver.connect(Driver.java:260)
[7/31/19 10:48:46:954 UTC] 0000007a id= R at java.sql.DriverManager.getConnection(DriverManager.java:675)
[7/31/19 10:48:46:955 UTC] 0000007a id= R at java.sql.DriverManager.getConnection(DriverManager.java:219)
我已按照文档 - https://cloud.ibm.com/docs/services/databases-for-postgresql?topic=databases-for-postgresql-external-app&locale=de创建 ssl 证书
Using the self-signed certificate
Copy the certificate information from the Connections panel or the Base64 field of the connection information.
If needed, decode the Base64 string into text.
Save the certificate to a file. (You can use the Name that is provided or your own file name).
Provide the path to the certificate to the driver or client.
String url = "jdbc:postgresql://**********.databases.appdomain.cloud:31260/ibmclouddb";
Properties props = new Properties();
props.setProperty("ssl","true");
props.setProperty("user","ibm_cloud_********");
props.setProperty("password","**************");
props.setProperty("sslmode","verify-full");
props.setProperty("sslcert","/opt/hb/postgres_cert/PGSSLCERT.crt"); props.setProperty("sslfactory","org.postgresql.ssl.jdbc4.LibPQFactory");