santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Mullan <Sean.Mul...@Sun.COM>
Subject Re: Able to decrypt xml but same enc xml throws decryptToByteArray decryptElement called without a key and unable to resolve
Date Tue, 26 Aug 2008 18:11:54 GMT
I strongly suggest first trying the latest apache xml security lib 
(1.4.2) to see if the problem still occurs.

Thanks,
Sean

Arsenal4Life wrote:
> Hi,
> 
> I am using jdk 1.4.2_09 and apache xml security lib 1.2.0.....
> code and enc xml attached...
> 
> http://www.nabble.com/file/p19133346/DomParserExample.java
> DomParserExample.java 
> 
> http://www.nabble.com/file/p19133346/Enc_type.xml Enc_type.xml 
> 
> I have to only decrypt the encrypted xml and I am able to do that in some
> cases. Lets say aj1.xml iam able to decrypt well, but then I make several
> copies like aj2.xml aj3.xml and so on and in some cases my program fails
> giving me this error message. I get the encrypted xml which is sent in email
> to me for testing purposes and I am copying that encrypted xml from outlook
> email and pasting it in editors like dreamweaver, editplus, notepad etc. 
> 
> Aug 24, 2008 11:53:25 AM org.apache.xml.security.encryption.XMLCipher
> decryptToByteArray
> SEVERE: XMLCipher::decryptElement called without a key and unable to resolve
> org.apache.xml.security.encryption.XMLEncryptionException: No Key Encryption
> Key loaded and cannot determine using key resolvers
> at org.apache.xml.security.encryption.XMLCipher.decryptToByteArray(Unknown
> Source)
> at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown
> Source)
> at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
> at DomParserExample.parseXmlFile(DomParserExample.java:229)
> at DomParserExample.runExample(DomParserExample.java:57)
> at DomParserExample.main(DomParserExample.java:278)
> 
> where line number 229 refers to this code  xmlCipher.doFinal(doc,
> encryptedDataElement);
> 
> My decryption code is below
> KeyStore ks = KeyStore.getInstance("JKS"); // Gets the Java Keystore   
>                    
> ks.load(new FileInputStream(new File(certPath)),password.toCharArray()); //
> loads the certificate   
> 
> RSAPrivateKey privKey = (RSAPrivateKey)
> ks.getKey("SamlTest",password.toCharArray());
> 
> // initialize cipher
> XMLCipher xmlCipher = XMLCipher.getInstance();
>              
> xmlCipher.init(XMLCipher.DECRYPT_MODE, null);   
>  
> xmlCipher.setKEK(privKey);
> 
> // do the actual decryption
> xmlCipher.doFinal(doc, encryptedDataElement);
> 
> // write the results to a file
> writeDecryptedDocToFile(doc, "original.xml");
> 
> What could be the issue here??? something to do with encrypted xml file???
> but why does it works sometimes for the same encrypted file and sometimes
> does not...
> 
> My email is ajashadi@gmail.com.
> 
> I saw a similar thread here but doesnt suggest the solution concerning my
> case......
> thread on nabble at this link
> http://www.nabble.com/Problem-decrypting-elements-td13434917.html#a13495256
> 
> Thanks,


Mime
View raw message