[英]How to connect to MySQL with X509 using JDBC?
我已經建立了一個MySQL(社區服務器,5.1)數據庫服務器。
我已經設置了SSL,創建了證書等。
我創建了一個具有REQUIRES X509屬性的用戶。
我可以使用命令行客戶端“mysql”使用此用戶進行連接,“status”命令顯示SSL處於活動狀態等。
我完全按照MySQL站點的說明將證書導入Java truststore / keystore文件。
我只是無法使用這些連接到數據庫。
如果我使用具有REQUIRES SSL的用戶只使用truststore文件,那么一切都很好。 使用帶有REQUIRES X509的用戶的密鑰庫文件就沒有了。
在網絡上似乎有很多證據表明人們正在努力解決這個問題並沒有多少答案。 有沒有人真的有這個工作?
在我的評論頁面底部列出了這里的破解: http : //dev.mysql.com/doc/refman/5.0/en/connector-j-reference-using-ssl.html
在花了一個星期的時間后,我終於設法使用客戶端certifiacte連接(需要用戶定義的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應用程序中指定受信任的certifcates文件(信任庫)和客戶端證書/密鑰文件(密鑰庫),或者System.setProperty(VAR,VAL),...
它確實有效!!!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.