santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Hummel <hum...@parityinc.net>
Subject Problems writing signed document to disk
Date Thu, 03 Apr 2008 20:27:50 GMT
Hi everyone,

Something weird is going on when I try to write my signed Document to  
disk...

					//doc is a Document which has gone through the signing process...
		Transformer xformer =  
TransformerFactory.newInstance().newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(new File("output.xml"));
		xformer.transform(source, result);

		
		DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance();
		dbf2.setNamespaceAware(true);
		DocumentBuilder db2 = dbf2.newDocumentBuilder();
		Document doc2 = db2.parse(new File("output.xml"));
		
		boolean res1 = CryptoUtils.verifyXmlSignature(doc);
		boolean res2 = CryptoUtils.verifyXmlSignature(doc2);
		
		System.out.println("RES 1 (raw) was " + res1);
		System.out.println("RES 2 (read) was " + res2);


This code prints out:

	
INFO  org.apache.xml.security.signature.Reference - Verification  
successful for URI "#IC01"
WARN  org.apache.xml.security.signature.Reference - Verification  
failed for URI "#IC01"
WARN  CryptoUtils - Signature was invalid
RES 1 (raw) was true
RES 2 (read) was false



any idea why writing the DOM to disk would make subsequent reads to  
validate it fail?

The only things I can think of are a) the Transformer is altering the  
document before writing it to disk or b) there are a lot of elements  
whose content is base64 encoded and making somehow they are getting  
mangled when written to disk?

Any help is appreciated!

- ian.
Mime
View raw message