如何让 javax.crypto 类(例如 javax.crypto.Cipher)在 jboss 的 servlet 上工作?

发布于 2024-11-27 16:04:29 字数 486 浏览 5 评论 0原文

我的应用程序验证许可证文件才能使其正常工作。它通过调用 javax.crypto.Cipher.getInstance("DES","SunJCE") 来解密许可证密钥文件。

当我在本地运行我的应用程序时,一切正常,但是当我使用 jboss 部署应用程序并达到我想要验证 servlet 上的许可证文件的程度时,我收到以下错误:

java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
  at javax.crypto.Cipher.getInstance(DashoA13*..)
  at javax.crypto.Cipher.getInstance(DashoA13*..)

就像我说的,它在命令提示符下工作正常和 eclipse,但不是作为 jboss 上的 servlet。有人知道我需要做什么吗?我使用 jdk 1.6 和 jboss as 7。

谢谢

My application validates a license file in order for it to work. It does this by calling javax.crypto.Cipher.getInstance("DES","SunJCE") inorder to decipher the license key file.

When I run my application locally everything works fine but when I deploy my application with jboss and get to the point where I want to validate the license file on the servlet, I get the following error:

java.lang.SecurityException: JCE cannot authenticate the provider SunJCE
  at javax.crypto.Cipher.getInstance(DashoA13*..)
  at javax.crypto.Cipher.getInstance(DashoA13*..)

Like I said, it works fine from command prompt and eclipse, but not as a servlet on jboss. Does anybody have any idea what I need to do? I am using jdk 1.6 and jboss as 7.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄想挽回 2024-12-04 16:04:29

有几个可能出现的问题,当 sun/oracle jvm 尝试验证提供者 jar 时,这似乎是类路径的问题

  • 检查所有安全 jar 是否都在 /jre 下运行jboss的jvm的/lib/ext
    (即 US_export_policy.jar、sunjce_provider.jar、local_policy.jar...)

  • 关于US_export_policy.jar和local_policy.jar请务必下载无限制版本

  • java.security 文件/jre/lib/security:确保有类似于 security.provider.X=com.sun.crypto.provider.SunJCE 的行,其中 X 是一个数字

  • 确保 sunJCE 提供程序 jar 不在您的 WEB-INF/lib 中

There are a couple of possible issues that come in mind, it seems to be a problem with classpath when sun/oracle jvm try to authenticate provider jars

  • check that all security jars are under the <jdk_home>/jre/lib/ext of the jvm that runs jboss
    (ie US_export_policy.jar, sunjce_provider.jar, local_policy.jar....)

  • about US_export_policy.jar and local_policy.jar be sure to have downloaded the unrestricted version

  • java.security file in <jdk_home>/jre/lib/security: be sure to have a line similar to security.provider.X=com.sun.crypto.provider.SunJCE where X is a number

  • be sure that sunJCE provider jar is not in you WEB-INF/lib

澉约 2024-12-04 16:04:29

我发现我的代码出了什么问题。在代码的早期部分,由于某种原因,有人执行了以下操作:

if (SunJCEinProviders) 
{
Security.removeProvider("SunJCE");
}   

int i = Security.insertProviderAt(new  com.sun.crypto.provider.SunJCE(),1);

因此,由于某种原因,我们删除了 javas 初始 SunJCE 提供程序,然后添加了一个新提供程序,但这个新提供程序无法通过身份验证。

I figured out what was wrong with my code. Earlier in the code for some reason someone did the following:

if (SunJCEinProviders) 
{
Security.removeProvider("SunJCE");
}   

int i = Security.insertProviderAt(new  com.sun.crypto.provider.SunJCE(),1);

So for some reason we were removing javas initial SunJCE provider then adding a new one and this new one was failing to be authenticated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文