猿问

如何使用 OpenSAML 2 和 Java 测试/调试解密加密断言?

我正在尝试与 OpenSAML2 (2.6.6) 一起编写 Java 应用程序来解密加密的断言,但我得到:


[main] ERROR org.opensaml.xml.encryption.Decrypter - Failed to decrypt EncryptedKey, valid decryption key could not be resolved

[main] ERROR org.opensaml.xml.encryption.Decrypter - Failed to decrypt EncryptedData using either EncryptedData KeyInfoCredentialResolver or EncryptedKeyResolver + EncryptedKey KeyInfoCredentialResolver

[main] ERROR org.opensaml.saml2.encryption.Decrypter - SAML Decrypter encountered an error decrypting element content

这是我的 Java 代码(抱歉,它仍然有很多调试输出):


/*

 * ****************************************************************************************************

 * Original source from: https://stackoverflow.com/questions/9422545/decrypting-encrypted-assertion-using-saml-2-0-in-java-using-opensaml

 * And hint about needed to add DefaultBootstrap.bootstrap() for OpenSAML 2.x: https://stackoverflow.com/questions/25066183/opensaml-error-receiving-correct-unmarshaller

 * And hing about chain resolvers: https://www.programcreek.com/java-api-examples/index.php?api=org.opensaml.saml2.encryption.Decrypter

 * ****************************************************************************************************

 * ****************************************************************************************************

 * ****************************************************************************************************

 * ****************************************************************************************************

 */

import java.io.File;

import java.io.FileInputStream;

import java.io.InputStream;

import java.security.KeyFactory;

import java.security.interfaces.RSAPrivateKey;

import java.security.spec.PKCS8EncodedKeySpec;

import java.util.ArrayList;

import java.util.List;



慕田峪9158850
浏览 204回答 2
2回答

元芳怎么了

仅供参考,一旦我找到正确的私钥以匹配示例加密断言,我终于可以按原样工作。

达令说

通过您的更改,我得到了 KEY LENGTH 已知错误,在点击以下链接后问题已解决org.apache.xml.security.encryption.XMLEncryptionException:非法密钥大小原始异常是 java.security.InvalidKeyException:非法密钥大小https://faq.miniorange.com/knowledgebase/i-am-getting-org-apache-xml-security-encryption-xmlencryptionexception-illegal-key-size-exception-sso/
随时随地看视频慕课网APP

相关分类

Java
我要回答