我正在使用openssl s_client -showcerts -connect test.abc.com:443 -state -debug来检查服务器证书。服务器正在使用nginx。但是当我请求上面的openssl时,服务器证书显示为* .xyz.com。我想知道openssl在哪里获得这个作为服务器证书。操作系统是Linux。签入/ etc / pki / tls但openssl读取的证书不是那里的服务器证书。并且nginx配置指向abc.com的正确证书。此外,如果我使用浏览器访问,则会显示正确的证书。这只发生在openssl上。 :(
答案 0 :(得分:4)
服务器正在向ethornetworks.com
发出永久重定向。要查看它,请先发出s_client
命令:
$ openssl s_client -CAfile AddTrustExternalCARoot.crt -connect apitest.ethormapp.com:443
CONNECTED(00000003)
depth=4 C = SE, O = AddTrust AB, OU = AddTrust External TTP Network, CN = AddTrust External CA Root
verify return:1
depth=3 C = US, ST = UT, L = Salt Lake City, O = The USERTRUST Network, OU = http://www.usertrust.com, CN = UTN - DATACorp SGC
verify return:1
depth=2 C = GB, ST = Greater Manchester, L = Salford, O = COMODO CA Limited, CN = COMODO Certification Authority
verify return:1
depth=1 C = GB, ST = Greater Manchester, L = Salford, O = COMODO CA Limited, CN = EssentialSSL CA
verify return:1
depth=0 OU = Domain Control Validated, OU = EssentialSSL Wildcard, CN = *.ethornetworks.com
verify return:1
...
在最底部,获得验证结果后,输入GET / HTTP/1.0
命令并按两次RETURN:
...
Start Time: 1390985154
Timeout : 300 (sec)
Verify return code: 0 (ok)
---
GET / HTTP/1.0
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.4
Date: Wed, 29 Jan 2014 08:46:01 GMT
Content-Type: text/html
Content-Length: 184
Connection: close
Location: https://www.ethornetworks.com/
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.4.4</center>
</body>
</html>
closed
$
如果您按照重定向进行操作,那么您将获得预期的结果:
$ openssl s_client -CAfile AddTrustExternalCARoot.crt -connect www.ethornetworks.com:443
CONNECTED(00000003)
depth=4 C = SE, O = AddTrust AB, OU = AddTrust External TTP Network, CN = AddTrust External CA Root
verify error:num=19:self signed certificate in certificate chain
verify return:0
---
Certificate chain
0 s:/OU=Domain Control Validated/OU=EssentialSSL Wildcard/CN=*.ethornetworks.com
i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=EssentialSSL CA
1 s:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=EssentialSSL CA
i:/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO Certification Authority
...
最后,您可以使用AddTrust External CA Root确保链验证符合预期。如果没有它和-CAfile
选项,s_client
将报告19 (self signed certificate in certificate chain)
。
答案 1 :(得分:4)
openssl存在SNI问题,请尝试使用此命令:
openssl s_client -showcerts -connect www.example.com:443 -servername www.example.com </dev/null
根据this article添加-servername应该清除它。