我正在使用Bouncy Castle安全提供程序进行加密/解密。我还确保在每次Bouncy castle呼叫后删除BC提供商。这是BC代码:
public static boolean pubVerifySign(
String pKey, String sSignature, String sChallenge) throws UnsupportedEncodingException{
BouncyCastleProvider bcp = initSecuritySubsystem();
boolean bOutput = false;
try{
ECPublicKey ecPublicKey =
getPublicKeyForBytes(Hex.decode(pKey));
bOutput =
pubVerifySign(ecPublicKey,
sSignature, sChallenge);
}finally{
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
}
return bOutput;
}
但是,就在代码之后。然而,每当我尝试使用URL.openConnection或任何其他Http库时,我得到以下错误:无系统TLS:
cz.msebera.android.httpclient.ssl.SSLInitializationException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore BKS implementation not found
at cz.msebera.android.httpclient.ssl.SSLContexts.createDefault(SSLContexts.java:57)
at cz.msebera.android.httpclient.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:978)
at cz.msebera.android.httpclient.impl.client.HttpClients.createDefault(HttpClients.java:56)
at org.nebucoin.user.utils.URLUtils.getHttp(URLUtils.java:63)Caused by: java.security.KeyManagementException: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore BKS implementation not found
at org.conscrypt.SSLParametersImpl.createDefaultX509KeyManager(SSLParametersImpl.java:534)
at org.conscrypt.SSLParametersImpl.getDefaultX509KeyManager(SSLParametersImpl.java:515)
at org.conscrypt.SSLParametersImpl.<init>(SSLParametersImpl.java:126)
at org.conscrypt.OpenSSLContextImpl.engineInit(OpenSSLContextImpl.java:104)
at javax.net.ssl.SSLContext.init(SSLContext.java:349)
at cz.msebera.android.httpclient.ssl.SSLContexts.createDefault(SSLContexts.java:52)
我已经尝试过无数其他Http Android库(OkHTTP、Apache Http客户端等(,但仍然会出现同样的错误。我甚至在项目中添加了Conscrypt官方安卓库,并将Conscrypt设置为第一个提供商,如下所示:
Security.insertProviderAt(Conscrypt.newProvider(), 1);
没有任何运气。
欢迎有任何想法!
注意:当我在基于BC/的pubVerifySign之前使用URL.openConnection时,一切都很好!
BouncyCastle有两个提供程序,您可能需要同时删除这两个。
Security.insertProviderAt(BouncyCastleProvider(), 1)
Security.insertProviderAt(BouncyCastleJsseProvider(), 2)
如果JSSE提供程序仍然存在,那么当它找不到所需的密钥库时,它将失败。