bouncycastle + JBoss AS7:JCE 无法验证提供者 BC [英] bouncycastle + JBoss AS7: JCE cannot authenticate the provider BC
问题描述
我在我的应用程序中使用 BouncyCastle 进行加密.当我独立运行它时,一切正常.但是,如果我将其放入 webapp 并部署在 JBoss 服务器上,则会出现以下错误:
I use BouncyCastle for encryption in my application. When I run it standalone, everything works fine. However, if I put it in the webapp and deploy on JBoss server, I get a following error:
javax.servlet.ServletException: error constructing MAC: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
(...)
root cause
java.lang.Exception: error constructing MAC: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
(...)
root cause
java.io.IOException: error constructing MAC: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
org.bouncycastle.jce.provider.JDKPKCS12KeyStore.engineLoad(Unknown Source)
java.security.KeyStore.load(Unknown Source)
这是导致此错误的代码的一部分:
Here is a part of the code that causes this error:
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null)
{
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
}
// Read the Private Key
KeyStore ks = KeyStore.getInstance("PKCS12", BouncyCastleProvider.PROVIDER_NAME);
ks.load(new FileInputStream(certificatePath), privateKeyPassword.toCharArray());
和 maven 依赖:
And maven dependency:
<dependency>
<groupId>bouncycastle</groupId>
<artifactId>bcmail-jdk16</artifactId>
<version>140</version>
</dependency>
你知道我如何部署它吗?
Do you know how could I deploy it?
推荐答案
不要将 bouncy-castle jar 部署为您的 web 应用程序 (WEB-INF/lib) 的一部分.你当然在编译时需要这个文件,但在 JBOSS 上它应该在这里:
Do not deploy the bouncy-castle jar as a part of your your webapp (WEB-INF/lib). You need this file in compiliation time of course, but on JBOSS it should be here:
$JBOSS_HOME/server/default/lib/
而不是
yourapp/WEB-INF/lib
这篇关于bouncycastle + JBoss AS7:JCE 无法验证提供者 BC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!