获取网站的https证书的问题

问题描述:

我有一个Android应用,通过https连接时,网站证书出现问题。由于即使在使用带有证书的自定义密钥库(“无对等证书”)时我遇到了麻烦,因此我试图获取有关服务器实际给出的连接,握手和证书的更多信息。获取网站的https证书的问题

OpenSSL版本是如下:

$ openssl version 
OpenSSL 1.0.1e 11 Feb 2013 

当我尝试获得有关证书的信息,我得到这样的响应:

$ openssl s_client -showcerts -connect [hostname]:443 </dev/null 
CONNECTED(00000003) 
3069977808:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:s23_clnt.c:749: 
--- 
no peer certificate available 
--- 
No client certificate CA names sent 
--- 
SSL handshake has read 7 bytes and written 308 bytes 
--- 
New, (NONE), Cipher is (NONE) 
Secure Renegotiation IS NOT supported 
Compression: NONE 
Expansion: NONE 
--- 

这是Chrome浏览器如何描述连接(抱歉挪威语的文字,但您会了解连接和加密类型: adf

根据来自Chrom的信息e我尝试了不同的命令来获得证书,但它们似乎都失败了。我的最佳人选是这一个:

$ openssl s_client -showcerts -connect [hostname]:443 -tls1_2 -cipher RC4-MD5 
CONNECTED(00000003) 
3069396176:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1258:SSL alert number 40 
3069396176:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:596: 
--- 
no peer certificate available 
--- 
No client certificate CA names sent 
--- 
SSL handshake has read 7 bytes and written 0 bytes 
--- 
New, (NONE), Cipher is (NONE) 
Secure Renegotiation IS NOT supported 
Compression: NONE 
Expansion: NONE 
SSL-Session: 
    Protocol : TLSv1.2 
    Cipher : 0000 
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    Key-Arg : None 
    PSK identity: None 
    PSK identity hint: None 
    SRP username: None 
    Start Time: 1414399499 
    Timeout : 7200 (sec) 
    Verify return code: 0 (ok) 
--- 

任何人根据给定的信息得到任何提示?

这可能是一个SNI问题,其中服务器没有为非SNI客户端定义默认证书。 Android包含了已知不支持SNI的Apaches httpclient版本,并且您的openssl s_client命令也不使用SNI。

请尝试openssl s_client -servername hostname -connect ...使用SNI,看看是否有帮助。

+0

哇,它看起来像你在现场!非常感谢! :-D使用SNI我拿到了证书。有点题目,但是你似乎对这个问题有所了解:当我从Apache的httpclient获得“无对等证书”时,你知道它是否可能是因为SNI问题?我看到服务器不返回中间证书或任何东西。 – 2014-10-27 09:26:25

+1

是的,这可能也是由于Android中附带的Apache httpclient中缺少SNI支持引起的。另请参阅http://blog.dev001.net/post/67082904181/android-using-sni-and-tlsv1-2-with-apache-httpclient了解可能的解决方法。 – 2014-10-27 11:16:47