Hi there, I try to verify a xml file with an enveloped signature. The signature was created with .NET and I'd like to verify that one with Java. My problem is that I got an exception during the signature verification. I use the code from the VerifySignature example. Parts of the stack trace is below as well as the xml file.
I'm not an expert about the Reference node but for me it looks fine. The URI is empty which indicates that the whole xml file except the signature node is signed by the signature. Is that explanation correct or have I missed something ? Do I need to perfrom the transformation before I verify the signature ? Thanks for your help. Marcel org.apache.xml.security.signature.XMLSignatureException: The Reference for URI has no XMLSignatureInput Original Exception was org.apache.xml.security.signature.MissingResourceFailureException: The Reference for URI has no XMLSignatureInput Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: The XPath is not in the same document as the context node Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: The XPath is not in the same document as the context node Original Exception was org.apache.xml.security.signature.XMLSignatureException: The XPath is not in the same document as the context node Original Exception was org.apache.xml.security.transforms.TransformationException: The XPath is not in the same document as the context node at org.apache.xml.security.signature.XMLSignature.checkSignatureValue(Unknown Source) at org.apache.xml.security.samples.signature.VerifySignature.main(VerifySignature.java:223) <sam:MarketplaceResponse xsi:schemaLocation="http://www.it.usyd.edu.au/comp5347/2004/SAM/Marketplace http://localhost/Marketplace/MarketplaceData.xsd" xmlns:sam="http://www.it.usyd.edu.au/comp5347/2004/SAM/Marketplace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <sam:Marketplace name="AlSaMa" version="1.0" location="Sydney"/> <sam:Status>Your sent file is valid!</sam:Status> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#" > <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> <Reference URI=""> <Transforms> <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> <DigestValue>ViPWYdtBY05hf8IkVJhpcIa+1dk=</DigestValue> </Reference> </SignedInfo> <SignatureValue>hOwp3+EJwFjPf6LGd1Thof/oJLTq14ZAm8DbTiFCqTGAfnz05TP0hkrzvt7ikOJqglACqnq9GBWJn1d6uxgBHeIcIEsWsJs2E+IE/CJRec5b4Brt7pBPcjHd9/LrWHE12ytpUUZEUZ8ggzqPGYdk4sy90X8lzo+jbdbOhXaA3mo27UX6JNHhbXS6kpDS4DSQ+38G5UEsW0DaieeSaMPPzu/EGH8mEXs/LQSi01sJHcVL8JoZn7+zJEzhJ6llJcF1dpBEAvM5E3GrOBeLfXP/FKfbijDopwKuQAXawP/ozl/WA4cWwfi+LcELUBYphwkOTEBt83nFbRMNqtggv9KIiA==</SignatureValue> <KeyInfo> <KeyValue xmlns="http://www.w3.org/2000/09/xmldsig#"> <RSAKeyValue> <Modulus>uCwbuqWyimZG9xv3MfEdTp7xtyutkZG5r71CJpE/p5+0wTbp8750g3s0hVu9mYNxmMM6xs4DyuKoVjJzWlaCgyu0ovibe+PAF3nKWzTRaFkm+ar23CcriG4R/3+dJIPmML3Ufus653ZGHnwUUewJMrFOK5yMg96PoGOogPr65UOfiYs2cDfu3cZRVxWdKEcWrPBSppxSHW+BwOxIrSE+VscHGnmhJuqndAiXKFbno1KJoAlIho98J4poQ4b3+TwqmVWEYIuKvgiBMRrLQ0qZiClbZaEmE9BUuDwEF9jClQ1kwVNPTqQXTT2/QKE3PnSNAymKVC1lgjydB7tJUFSnFQ==</Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue> </KeyValue> </KeyInfo> </Signature> </sam:MarketplaceResponse> -- NEU : GMX Internet.FreeDSL Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/dsl