从URL连接请求获取SSL证书详细信息

时间:2013-07-19 15:53:32

标签: android httpclient urlconnection httpsurlconnection

在android中,我想建立一个到HTTPS URL的URL连接。连接打开后,我希望能够从服务器读取证书并获取已发布的通用名称和组织字符串吗?

这可能吗?如果是这样,最好的方法是什么?

到目前为止,我一直在使用HttpsUrlConnection:

HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.getInputStream();
X509Certificate cert = (X509Certificate) urlConnection.getServerCertificates()[0];

但在此之后,我不确定如何获得具体的证书详情?如果这是正确的做法,我甚至不确定。

0 个答案:

没有答案