![](/img/trans.png)
[英]Can't setup mysql database for fabric-ca server due to certificate error
[英]Can I use openssl s_client to retrieve the CA certificate for MySQL?
我可以使用openssl s_client
來檢索 MySQL 的 CA 證書嗎?
我可以使用以下命令訪問遠程數據庫服務器
mysql -u theuser -h thehost --ssl --ssl-cipher=DHE-RSA-AES256-SHA -p thedatabase
現在我想使用 JDBC 連接到它。
我意識到我需要將公共證書插入我的 Java 密鑰庫。 但是,我不知道如何檢索公共證書。 我意識到它位於/etc/mysql/ca.pem
或類似位置的遠程服務器上。 但是,我無權將該文件甚至ssh
讀入機器。
我試過了
openssl s_client -cipher DHE-RSA-AES256-SHA -connect thehost:3306
和一些變化。 我總是出錯。 例如
CONNECTED(00000003)
30495:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:/BuildRoot/
Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-59/src/ssl/s23_clnt.c:618:
我可以使用openssl s_client檢索MySQL的CA證書嗎?
你可能做不到。
配置正確的服務器將發送服務器證書和構建到根CA的路徑所需的所有中間證書。 您必須已經具有根CA證書。
例如:
$ openssl s_client -connect www.cryptopp.com:443 -tls1 -servername www.cryptopp.com
CONNECTED(00000003)
depth=2 C = GB, ST = Greater Manchester, L = Salford, O = COMODO CA Limited, CN = COMODO RSA Certification Authority
verify error:num=20:unable to get local issuer certificate
---
Certificate chain
0 s:/OU=Domain Control Validated/OU=COMODO SSL Unified Communications
i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
1 s:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
2 s:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Certification Authority
i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
---
...
服務器發送了服務器的證書。 上面顯示為0 s:/OU=Domain Control Validated/OU=COMODO SSL Unified Communications
。 S
表示其主題,而I
表示其發行者。
服務器在1
和2
發送了兩個中間證書。 但是,我們需要在本地擁有證書2的頒發者才能構建驗證路徑。 證書2的頒發者的通用名稱為 “ AddTrust External CA Root” 。
可以從Comodo的站點[Root]上下載“ AddTrust外部CA Root”。
如果服務器發送了根CA,那么一個壞人可能會篡改該鏈,而客戶端則不會更明智。 他們可以交換自己的CA並使用邪惡鏈。
我們可以通過獲取根CA,然后使用-CAfile
來清除verify error:num=20:unable to get local issuer certificate
:
$ openssl s_client -connect www.cryptopp.com:443 -tls1 -servername www.cryptopp.com \
-CAfile addtrustexternalcaroot.pem
這將導致Verify Ok (0)
。
是的,OpenSSL 版本 1.1.1(2018 年 9 月 11 日發布)現在支持從 MySQL 服務器獲取服務器證書。
openssl s_client -starttls mysql -connect thehost:3306
資料來源: Paul Tobias 的回答
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.