如何让 javax.crypto 类(例如 javax.crypto.Cipher)在 jboss 的 servlet 上工作?
我的应用程序验证许可证文件才能使其正常工作。它通过调用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几个可能出现的问题,当 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 tosecurity.provider.X=com.sun.crypto.provider.SunJCE
where X is a numberbe sure that sunJCE provider jar is not in you WEB-INF/lib
我发现我的代码出了什么问题。在代码的早期部分,由于某种原因,有人执行了以下操作:
因此,由于某种原因,我们删除了 javas 初始 SunJCE 提供程序,然后添加了一个新提供程序,但这个新提供程序无法通过身份验证。
I figured out what was wrong with my code. Earlier in the code for some reason someone did the following:
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.