Java Security将Provider设置为SSLContext

时间:2018-01-11 16:35:49

标签: java security ssl-certificate x509

如何为SSL上下文设置安全提供程序?

我的代码就像

Security.insertProviderAt(new XXX(), 1);///XXX is a Security Provider
KeyStore clientStore = KeyStore.getInstance("PKCS12");
clientStore.load(new FileInputStream(p12FileName), p12FilePass.toCharArray());

KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientStore, p12FilePass.toCharArray());
KeyManager[] kms = kmf.getKeyManagers();
sslContext = SSLContext.getInstance("TLS");
sslContext.init(kms, null, new SecureRandom());

如果我删除了提供商XXX或将SunEC设置为优先提供商,那么一切正常。但由于某种原因,我无法做到这两点。有没有办法在REST调用的SSL上下文中将提供程序设置为SunEC而不更改第一行Security.insertProviderAt(new XXX(), 1)

0 个答案:

没有答案