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 [EMAIL PROTECTED] 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, -- View this message in context: http://www.nabble.com/Able-to-decrypt-xml-but-same-enc-xml-throws-decryptToByteArray-decryptElement-called-without-a-key-and-unable-to-resolve-tp19133346p19133346.html Sent from the Apache XML - Security - Dev mailing list archive at Nabble.com.