我已经设置了 MySQL(社区服务器,5.1)数据库服务器。
我已经设置了 SSL、创建了证书等。
我创建了一个具有 REQUIRES X509 属性的用户。
我可以使用命令行客户端“mysql”使用此用户进行连接,并且“status”命令显示 SSL 处于活动状态等。
我完全按照 MySQL 站点上有关将证书导入 Java 信任库/密钥库文件的说明进行操作。
我只是无法使用这些连接到数据库。
如果我仅使用具有 REQUIRES SSL 的用户的信任库文件,那么一切都很好。与需要 X509 的用户一起使用密钥库文件只是没有它。
网络上似乎有很多证据表明人们正在为此苦苦挣扎,但答案却不多。有人真正做到了这一点吗?
已破解,在页面底部我的评论中列出:http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-using-ssl.html
经过一周的努力,我终于成功地使用客户端证书进行连接(用户定义上需要 X509)!!!!
rem NOTE: these commands are run using the Java 6 (1.6) JDK as it requires the "-importkeystore" command
rem which is not available before this JDK version.
rem Import the self signed Certifacte Authority certificate into a keystore.
keytool -import -alias mysqlCACert -file ca-cert.pem -keystore truststore -storepass truststore
rem Shows only the signed certificate.
keytool -v -list -keystore truststore -storepass truststore
rem Create a PKCS12 file from an existing signed client certifcate and its private key.
rem set password to "keystore".
openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem -out client.p12 -name clientalias -CAfile ca-cert.pem -caname root
rem Import the combined certificate and private key into the keystore.
keytool -importkeystore -deststorepass keystore -destkeystore keystore -srckeystore client.p12 -srcstoretype PKCS12 -srcstorepass keystore -alias clientalias
然后通过连接 URL、JVM 启动参数 (-D=,...) 或 Java 应用程序中指定受信任的证书文件(信任库)和客户端证书/密钥文件(密钥库) System.setProperty(var,val),...
它确实有效!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)