Hey guys.

Normally I wouldn't bother anyone. But I have only been programming Java for three months, I come from a .NET background, and after three days of researching and attempting I cannot find the solution to what would seem as a simple problem.

Basically I am using the javax.xml.crypto.dsig.XMLSignatureFactory to generate XML Signatures. Now when I try to validate the generated signature with java, the validation succeeds, however when I attempt the validation with .NET the validation fails.

I have eliminated every other option and discrepancy between an XMLDSIG file generated by .NET and an XMLDSIG file generated by java and have narrowed it down to what seems like the only possible problem left.

Basically, when rendering BASE64 Encoded Objects, Java adds a break line after the 76th character to produce separate lines. On the other hand .NET does not exhibit this behavior.

Searching on the internet one will find many posts which describe that the extra lines is what causes many validation mechanisms to fail.

Now I have tried setting org.apache.xml.security.ignoreLineBreaks system property to true at the beginning of my application and calling org.apache.xml.security.Init.init();, and when I retrieve the property it is set to true. However, unlike what happened to other users where by the BASE64 Encoder did not include the break lines, in mine it still is including the break lines.

Does anyone have any idea how to force the XMLSignature to not include break lines in BASE64 objects rendered??

If you require more information please don't hesitate to ask. I'm with my back against the wall so I will accept any input at this point.

Below find examples of .NET and Java Signatures. The .NET Signature below is validated by the .NET Validation Process, but the Java Signature is not validated by the .NET Validation Process.

.NET Signature

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<form xml:lang="en">
<Name>Justin</Name>
<Surname>Azzopardi</Surname>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
<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#WithComments"/>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>H6PgIF0h0NA4Mv4u3TqhhCZ1qx0=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>OdRD6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Ji7GX7fLpC61NNGL4+/BPJf7kUqxy6q02o48TGrP9tvtl/QlYAw/dtSLa9wEU/Pdy3sFAvVQdwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBVmiRo AMC9h+zsKAVWdH8F7P/2d7PHXYodDC+k/Iq0tRW8NXGsdxw8jnHpZUQRfjl+WwaKuEgLQdluZY3KXDfVDnV 6x7LYKzmimaDpXK4KLjMv/wZ3BNBFT1fYZPMJ1DTYr9reYZC4xrQ3CZGbUUCqsDQdqMDk/XdVgUJwsqpL0OerDsPL7MyX3JHI8ONl3ljAcWL17TKTR/Ep6jTEZeGhija6AY8Qd1uL9pxvnV4tabQSwgiiqrUkE8AtJJEy 8tnMcYpIXeBFDfJnIB1d+W48Xhj6hXT9VX4fmjT+SVp8HDsxNI K7d2/oqn49XFLTDiDwTYUAU11AHeTNncyUx8Z1</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</form>

Java Signature

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<form xml:lang="en">
<Name>Justin</Name>
<Surname>Azzopardi</Surname>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
<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#WithComments"/>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>W8GGHced05XLJkZ7zZXt+wbVcSE=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>k6o0uxDpPKZxe7xCRAcDPgqV8ZPnehUW1F 9hDH8WoDmDDdc8exKfat8t6uGsTA2gfeafaebobx+i
LSVKImePWqRiYndiGJhZ1dP8LxWH4h6eAitRYjBg+5pFqeQ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