我输入了openssl s_client -debug -connect google.com:443
并获得了google.com
的证书。作为响应,有证书链和服务器证书数据。我可以使用以下代码获取证书链:
Certificate[] serverCerts = httpsUrlConnection.getServerCertificates();
for (int i = 0; i < serverCerts.length; i++)
{
X509Certificate x509cert = (X509Certificate) serverCerts[i];
BigInteger serialNum = x509cert.getSerialNumber();
String name = x509cert.getIssuerDN().getName();
String publicKeySerial = serialNum.toString(16);
}
但是我无法在Android中获取服务器证书数据。我该怎么办?