HOW TO SIGN XML FILE IN .NET COMPACT EDITION
.NET (Core and Framework)
1
Posts
1
Posters
0
Views
1
Watching
-
I need help for sign an XML files with (signature tag). Nothing problem if the platform is a standard PC but in .NET COMPACT FRAMEWORK for windows mobile 6 I have problems. First .. exist Systems.Security in .NET CF? 2.0 or 3.5? Where are? this is my code for Pc ..:
Public Function Firma(ByVal XmlFile as String) As Boolean
Dim signedXML as String = "c:\signedXML.xml"
' setup the document to sign
Dim doc As XmlDocument = New XmlDocument()
doc.Load(XmlFile)
Dim signer As SignedXml = New SignedXml(doc)'setup the key used to sign Dim key As Security.Cryptography.RSA = New Security.Cryptography.RSACryptoServiceProvider() signer.KeyInfo = New Security.Cryptography.Xml.KeyInfo() signer.KeyInfo.AddClause(New Security.Cryptography.Xml.RSAKeyValue(key)) signer.SigningKey = key 'create a reference to the root of the document Dim orderRef As Security.Cryptography.Xml.Reference = New Security.Cryptography.Xml.Reference("") orderRef.AddTransform(New Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform()) orderRef.DigestMethod = "http://www.w3.org/2001/04/xmlenc#sha256" signer.AddReference(orderRef) 'add transforms that only select the order items, type, and 'compute the signature, and add it to the document signer.ComputeSignature() doc.DocumentElement.AppendChild(signer.GetXml()) doc.Save(signedXML)
End Function
Alex