org.apache.xml.security.encryption.XMLEncryptionException:非法密钥大小或默认参数
您好,当我尝试在 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 技术交流群。
发布评论
评论(3)
欢烬2024-12-16 03:42:46
使用“Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6”更新 JDK 库后,问题得到解决。
自此以后,行同陌路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 及更高版本默认使用无限制的策略文件。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
这有帮助吗?: http://blog.rampartfaq.com/2009/ 08/faq-001-javasecurityinvalidkeyexception.html
Does this help?: http://blog.rampartfaq.com/2009/08/faq-001-javasecurityinvalidkeyexception.html