我可以使用 openssl s_client 检索 MySQL 的 CA 证书吗?
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 连接到它。
我意识到我需要 insert the public certificate into my Java key store。但是,我不知道如何检索 public 证书。我意识到它位于 /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:
Can I use openssl s_client to retrieve the CA certificate for MySQL?
你可能做不到。
配置良好的服务器将发送服务器证书和构建根 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
和[=发送了两个中间证书16=]。但是,我们需要在本地拥有证书 2 的颁发者来构建验证路径。证书 2 的颁发者使用 Common Name "AddTrust External CA Root".
"AddTrust External CA Root" 可以从 Comodo 的网站下载 [Root] AddTrust External CA Root
如果服务器发送了根 CA,那么坏人就可以篡改链条,客户端也不会更聪明。他们可以换入自己的 CA 并使用邪恶链。
我们可以清除verify error:num=20:unable to get local issuer certificate
通过获取根CA,然后使用-CAfile
:
$ openssl s_client -connect www.cryptopp.com:443 -tls1 -servername www.cryptopp.com \
-CAfile addtrustexternalcaroot.pem
它会导致 Verify Ok (0)
.
我可以使用 openssl s_client
检索 MySQL 的 CA 证书吗?
我可以使用以下方法访问远程数据库服务器
mysql -u theuser -h thehost --ssl --ssl-cipher=DHE-RSA-AES256-SHA -p thedatabase
现在我想使用 JDBC 连接到它。
我意识到我需要 insert the public certificate into my Java key store。但是,我不知道如何检索 public 证书。我意识到它位于 /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:
Can I use openssl s_client to retrieve the CA certificate for MySQL?
你可能做不到。
配置良好的服务器将发送服务器证书和构建根 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
和[=发送了两个中间证书16=]。但是,我们需要在本地拥有证书 2 的颁发者来构建验证路径。证书 2 的颁发者使用 Common Name "AddTrust External CA Root".
"AddTrust External CA Root" 可以从 Comodo 的网站下载 [Root] AddTrust External CA Root
如果服务器发送了根 CA,那么坏人就可以篡改链条,客户端也不会更聪明。他们可以换入自己的 CA 并使用邪恶链。
我们可以清除verify error:num=20:unable to get local issuer certificate
通过获取根CA,然后使用-CAfile
:
$ openssl s_client -connect www.cryptopp.com:443 -tls1 -servername www.cryptopp.com \
-CAfile addtrustexternalcaroot.pem
它会导致 Verify Ok (0)
.