org.apache.xml.security.encryption.XMLEncryptionException:非法密钥大小或默认参数

发布于 12-09 03:42 字数 1475 浏览 0 评论 0原文

您好,当我尝试在 spring ws 配置中添加安全加密 Sym 算法时,它给出了以下异常

Caused by: org.apache.ws.security.WSSecurityException: Cannot encrypt data; nested exception is: 
    org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters
Original Exception was java.security.InvalidKeyException: Illegal key size or default parameters
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:599)
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:459)
    at org.apache.ws.security.message.WSSecEncrypt.encryptForInternalRef(WSSecEncrypt.java:348)
    at org.apache.ws.security.message.WSSecEncrypt.build(WSSecEncrypt.java:309)
    at org.apache.ws.security.action.EncryptionAction.execute(EncryptionAction.java:62)
    ... 20 more
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters
Original Exception was java.security.InvalidKeyException: Illegal key size or default parameters
    at org.apache.xml.security.encryption.XMLCipher.encryptData(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.encryptData(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.encryptElement(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:593)
    ... 24 more

Hi when i am trying to add securement Encryption Sym Algorithm in spring ws configuration it is giving following exception :

Caused by: org.apache.ws.security.WSSecurityException: Cannot encrypt data; nested exception is: 
    org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters
Original Exception was java.security.InvalidKeyException: Illegal key size or default parameters
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:599)
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:459)
    at org.apache.ws.security.message.WSSecEncrypt.encryptForInternalRef(WSSecEncrypt.java:348)
    at org.apache.ws.security.message.WSSecEncrypt.build(WSSecEncrypt.java:309)
    at org.apache.ws.security.action.EncryptionAction.execute(EncryptionAction.java:62)
    ... 20 more
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters
Original Exception was java.security.InvalidKeyException: Illegal key size or default parameters
    at org.apache.xml.security.encryption.XMLCipher.encryptData(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.encryptData(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.encryptElement(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
    at org.apache.ws.security.message.WSSecEncrypt.doEncryption(WSSecEncrypt.java:593)
    ... 24 more

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

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

发布评论

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

评论(3

缪败2024-12-16 03:42:46

这有帮助吗?: http://blog.rampartfaq.com/2009/ 08/faq-001-javasecurityinvalidkeyexception.html

您需要使用 Java 加密扩展 (JCE) 无限强度管辖策略文件修补您的 JDK。

Does this help?: http://blog.rampartfaq.com/2009/08/faq-001-javasecurityinvalidkeyexception.html

You need to patch your JDK with Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

欢烬2024-12-16 03:42:46

使用“Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6”更新 JDK 库后,问题得到解决。

您可以从 http://www.oracle.com/downloads/jce-6-download-429243.html 下载库。 oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

After Updating the JDK library with "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6" the problem was resolved.

you can download library from http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

自此以后,行同陌路2024-12-16 03:42:46

这是一个相当老的问题(答案中的链接要么不起作用,要么不提供最新 java 版本的详细信息)。

我最近遇到了这个问题,想添加更多细节。

根本原因:
Java 8及更早版本默认不支持256位AES加密的密钥;仅支持 128 位 AES 加密。

解决方案:
可以通过安装 Oracle Java JCE 无限强度 jar 来解决问题。点击以下链接下载 Java 8 及更早版本的 jar: Java 加密扩展 (JCE) 无限强度管辖策略文件

Jar 文件适用于 Java 版本 6、7 和 8。

通过接受许可协议下载 zip 文件,解压缩并将这些 jar 文件复制到 $JAVA_HOME/jre/lib/security/ 目录。重新启动应用程序(如果已运行)以使 jar 生效。

Java 9 及更高版本默认使用无限制的策略文件。

This is pretty old question(Links in the answers are either not working or does not provide details for latest java versions).

I faced the issue recently and would like to add more details.

Root Cause:
Java 8 and earlier versions does not support keys with 256-bit AES encryption by default; only 128-bit AES encryption is supported.

Solution:
Issue can be resolved by installing the Oracle Java JCE unlimited strength jars. Follow the link to download the jars for Java 8 and earlier versions: Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.

Jar files are available for Java versions 6, 7 and 8.

Download the zip file by accepting license agreement, unzip it and copy these jar files to $JAVA_HOME/jre/lib/security/ directory. Restart application, if running already, for the jars to take effect.

Java 9 and later uses the unlimited policy files by default.

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