Java MySQL-jdbc+;SSL

Java MySQL-jdbc+;SSL,java,mysql,sockets,ssl,jdbc,Java,Mysql,Sockets,Ssl,Jdbc,我为启用SSL的MySQL客户端设置了系统属性,该客户端运行良好: System.setProperty("javax.net.ssl.trustStore","truststore"); System.setProperty("javax.net.ssl.trustStorePassword","12345"); String url = "jdbc:mysql://abc.com:3306/test?" + "user=abc&password=123" +

我为启用SSL的MySQL客户端设置了系统属性,该客户端运行良好:

System.setProperty("javax.net.ssl.trustStore","truststore");
System.setProperty("javax.net.ssl.trustStorePassword","12345");
String url = "jdbc:mysql://abc.com:3306/test?" +
             "user=abc&password=123" +
             "&useUnicode=true" +
             "&characterEncoding=utf8&useSSL=true"
几天前,我发现客户端无法连接到另一个安装了商业签名SSL证书的网站。显然,覆盖的密钥库不适用于常规https连接。 然后我决定在MySQL Connector/J源代码中基于StandardSocketFactory.java构建我的SocketFactory版本

我在publicsocketconnect(stringhostname,intportnumber,Properties)方法中添加了一个创建套接字对象的方法

传递给jdbc驱动程序的url更改为:

    String url = "jdbc:mysql://abc.com:3306/test?" +
             "user=abc&password=123" +
             "&useUnicode=true" +
             "&characterEncoding=utf8&useSSL=true" +
             "&socketFactory=" + MySocketFactory.class.getName();
客户端确实执行了我的版本createSSLSocket(),并返回了一个套接字对象。但是,在继续执行之后,我得到了以下异常:

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
    Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    javax.net.ssl.SSLException: 
    Unrecognized SSL message, plaintext connection?
我确信MySQL已经启动并运行,传递给createSSLSocket()的地址和端口是正确的。有人能帮忙吗?客户端必须同时与两个站点通信:一个HTTPS web服务器和一个自签名MySQL服务器

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
    Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    javax.net.ssl.SSLException: 
    Unrecognized SSL message, plaintext connection?