XML whitespace issue...

J

Joe Van Meer

HI there,

I have a .NET 2.0 DLL that I use to digitally sign an X509Certificate - this
DLL is COM Interop enabled and is being called via a classic ASP page.

My main method in the DLL takes in an XML string and digitally encrypts it
using values form an X509Certificate on the server, and sends it back
(currently xmlDoc.OuterXML.ToString() - a method (outerxml) I am now finding
out strips out any whitespaces found in the elements)

I call this method and place this resulting object into an XMLDOM object and
dump this value into a hidden form field for a POST action - obj.xml

The issue is that I am trying to preserve the line breaks in the
X509Certificate element inside the signature, however it all comes back as
one line when I view it in view Source of my browser, and doesn't not
complete my SSO action that is expecting the line breaks...

My question is this, is there a reliable way to preserve this whitespace, or
another route I could take to get the xml in it's original format? Is
there a way to identfy these breaks within the element b4 I send it back and
do some sort of replace action?

cheers & thanks, Joe
 
P

Pavel Minaev

I have a .NET 2.0 DLL that I use to digitally sign an X509Certificate - this
DLL is COM Interop enabled and is being called via a classic ASP page.

My main method in the DLL takes in an XML string and digitally encrypts it
using values form an X509Certificate on the server, and sends it back
(currently xmlDoc.OuterXML.ToString() - a method (outerxml) I am now finding
out strips out any whitespaces found in the elements)

That method doesn't do that. It may strip "insignificant" whitespace
according to the XML spec (or rather, XmlReader and/or XmlWriter may
do that, since XmlDocument is just an in-memory representation), but
that's not the same. In any case, if you work on DOM level, it
shouldn't do it. It must be something else - if you show the code,
then it may be possible to tell what's wrong.
 
J

Joe Van Meer

Thx for reply Pavel,

I am still having issues and have reposted the method's code in this forum
today (27th) . Not sure if you can take a look or not, but the xmldoc I have
is getting signed ok, and I took your advice to use the save() to the
server. I did this and my X509Certificate element's data is still in one
line unfortunately.

cheers mate, joe

I have a .NET 2.0 DLL that I use to digitally sign an X509Certificate -
this
DLL is COM Interop enabled and is being called via a classic ASP page.

My main method in the DLL takes in an XML string and digitally encrypts it
using values form an X509Certificate on the server, and sends it back
(currently xmlDoc.OuterXML.ToString() - a method (outerxml) I am now
finding
out strips out any whitespaces found in the elements)

That method doesn't do that. It may strip "insignificant" whitespace
according to the XML spec (or rather, XmlReader and/or XmlWriter may
do that, since XmlDocument is just an in-memory representation), but
that's not the same. In any case, if you work on DOM level, it
shouldn't do it. It must be something else - if you show the code,
then it may be possible to tell what's wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top