我正在以标准方式创建SSLContext:
问题是 - 如何从SSLContext中提取KeyStore和证书数据?任务是从certficate获取指纹哈希。
是否可以或者我必须单独获取它,从文件中读取证书?
答案 0 :(得分:0)
如果您有自定义TrustManager,则可以执行此操作。您可以为该自定义类引用此link。寻找私有的if (selected == "yes") { // here's where we test the contents of "selected"
document.getElementById('fnlMsg').innerHTML = msg;
} else {
document.getElementById('fnlMsg').innerHTML = "<strong>"+fname.value+"</strong>, thank you for your feedback!";
}
静态类。
使用java的默认TrustManager的地方,使用此类,以便您可以检索服务器发送的证书。
SavingTrustManager
启动握手后,您可以从静态成员变量SSLContext context = SSLContext.getInstance("TLS");
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(dummyTrustStore);
X509TrustManager defaultTrustManager = (X509TrustManager) tmf.getTrustManagers()[0];
SavingTrustManager savingTrustManager = new SavingTrustManager(defaultTrustManager);
context.init(null, new TrustManager[] { savingTrustManager }, null);
SSLSocketFactory factory = context.getSocketFactory();
获取SavingTrustManager中的证书,如:
savingTrustManager.chain