为 X509TrustManager
实现 checkServerTrusted
方法的推荐方法是什么?我需要为 ssl pinning 使用重新实现,但我一直只能看到这个实现:
public void checkServerTrusted(X509Certificate[] certificates, String authType)
throws CertificateException {
if ((certificates != null) && (certificates.length == 1)) {
certificates[0].checkValidity();
} else {
standardTrustManager.checkServerTrusted(certificates, authType);
}
}
取自此response .但是在我看来这似乎是错误的。 它只检查证书是否有效(未过期),不检查其他内容。
请问您有什么实现方案可以推荐给我吗?
最佳答案
好的,解决方案不是使用自定义 TrustManagers
,而是使用我固定的 ssl 证书初始化 KeyStore
。
关于android - 为 X509TrustManager 实现 checkServerTrusted 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45008122/