Signed XML visualisation in browser

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all,
I have a digitally signed sample XML file:
<?xml version="1.0" encoding="UTF-8"?><br/>
<?xml-stylesheet type="text/xsl test.xsl"?><br/>
<Address><br/>
<Town>New York</Town><br/>
<Signature xmlns=" http://www.w3.org/2000/09/xmldsig http://www.w3.org/2000/09/xmldsig #
<SignedInfo><CanonicalizationMethod Algorithm=" http://www.w3.org/TR/2001/REC-xml-c14n-20010315 http://www.w3.org/TR/2001/REC-xml-c14n-20010315 " />
<SignatureMethod Algorithm=" http://www.w3.org/2000/09/xmldsig#rsa-sha1 http://www.w3.org/2000/09/xmldsig#rsa-sha1 " />
<Reference URI="
<Transforms><Transform Algorithm=" http://www.w3.org/2000/09/xmldsig#enveloped-signature http://www.w3.org/2000/09/xmldsig#enveloped-signature " /></Transforms>
<DigestMethod Algorithm=" http://www.w3.org/2000/09/xmldsig#sha1 http://www.w3.org/2000/09/xmldsig#sha1 " />
<DigestValue>...........</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>...........</SignatureValue>
<KeyInfo>
<KeyValue>
<RSAKeyValue><Modulus>......</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
<KeyName>AAA</KeyName>
<X509Data>
<X509Certificate>MII........</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</Address>

I want to visualise the XML file in browser through XSL file:
<?xml version="1.0" encoding="UTF-8"?><br/>
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform http://www.w3.org/1999/XSL/Transform <br/>
<xsl:output method="html"/>
<xsl:template match="Address <br/>
<html><br/>
<head><br/>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/><br/>
</head><br/>
<body>
<xsl:variable name="X509Certificate" select="//X509Data/X509Certificate/text()"/><br/>
<br/>
<script type="text/javascript <br/>
var cert=<xsl:value-of select="$X509Certificate"/>;<br/>
function DefCertInfo(acert) {<br/>
try {
var v_cert=new ActiveXObject(CAPICOM.Certificate);<br/>
v_cert.Import(acert);<br/>
v_cert.Display();<br/>
return false;<br/>
}<br/>
catch(e) {<br/>
alert(Please register CAPICOM.DLL);<br/>
return false;<br/>
}<br/>
}<br/>
</script>
<table width="100% <br/>
<tr><br/>
<td><br/>
Town: <xsl:value-of select="/Address/Town"/> <br/>
</td><br/>
</tr><br/>
</table><br/>
<table with="100% <br/>
<tr><br/>
<td> Certificate: <br/>
#" onclick="DefCertInfo(cert); <span class="italicsign Sign <br/>
</td><br/>
</tr><br/>
</table><br/>
</body><br/>
</html> <br/>
</xsl:template><br/>
</xsl:stylesheet>
When XML is rendered in the browser (IE9) the variable cert is empty.
I can not get the key from KeyInfo/X509Data/X509Certificate
The XML is signed by procedure from here: http://msdn.microsoft.com/en-us/library/x8xwex4b.aspx
http://msdn.microsoft.com/en-us/library/x8xwex4b.aspx
I tried also:
<xsl:variable name="X509Certificate" select="/Address/Signature/KeyInfo/X509Data/X509Certificate"/>
without success.

It is interesting that when I change the line
from <Signature xmlns=" http://www.w3.org/2000/09/xmldsig http://www.w3.org/2000/09/xmldsig #
to <Signature xmlns:=" http://www.w3.org/2000/09/xmldsig http://www.w3.org/2000/09/xmldsig # then I can visualise the certificate.
Can anybody help me with the problem?

Best Regards

View the full article
 
Back
Top