我从我的Java应用程序连接到MySQL over SSL.我已将MYSQL配置为支持SSL并生成客户端证书.我已将服务器CA证书和客户端证书导入密钥库.这就是我的代码目前的样子
String url = "jdbc:mysql://127.0.0.1:3306/MySampleDb? verifyServerCertificate =true&useSSL=true&requireSSL=true"
System.setProperty("javax.net.ssl.keyStore","/home/cert/keystore");
System.setProperty("javax.net.ssl.keyStorePassword","password");
System.setProperty("javax.net.ssl.trustStore","/home/cert/truststore");
System.setProperty("javax.net.ssl.trustStorePassword","password");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url, user, password);
我想使用带有C3p0的spring通过SSL连接到MYSQL.这是我的spring配置文件,它从jdbc.properties读取参数.
........
如何配置弹簧来设置属性
verifyServerCertificate = true
useSSL =真
requireSSL =真”
也可以在spring配置文件中设置keyStore和trustStore值.