Hi everyone!
I have a code to sign one XML using msxml5 and work perfect BUT the msxml5 is including only in the Office, so I am trying to convert my code to class of FrameWork to sign and I get the same value in the <DigestValue> but different value in the <SignatureValue> and of course I have using the same Certificate. So when I check the signature of the document XML with other application they say that is wrong the signature.
Here is the code to sign using the framework class (Visual Basic 2005 .NET) and I using the deattach signature:
dim id_container as string = "{10CA2CE8-A17E-436A-BB62-22B98F36CDA6}"
dim FileName as string ="c:\demo.xml"
Dim
cspParams As New CspParameterscspParams.KeyContainerName = id_container
cspParams.ProviderType = 1
cspParams.KeyNumber = 2
Dim key As New RSACryptoServiceProvider(cspParams) Dim doc As New XmlDocument()doc.PreserveWhitespace =
Truedoc.Load(FileName)
Dim signer As New SignedXml(doc)
signer.KeyInfo =
New KeyInfosigner.KeyInfo.AddClause(
New RSAKeyValue(key))signer.SigningKey = Key
Dim referencia As New Reference()referencia.Uri =
"#SetDoc"referencia.AddTransform(
New XmlDsigC14NTransform())signer.AddReference(referencia)
signer.SignedInfo.SignatureMethod = SignedXml.XmlDsigRSASHA1Url
signer.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigCanonicalizationUrl
signer.ComputeSignature()
'------------------------------------------------------------------------------------ Dim xmlDigitalSignature As XmlElement = signer.GetXml()doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature,
True)) If TypeOf doc.FirstChild Is XmlDeclaration Thendoc.RemoveChild(doc.FirstChild)
End If Dim vencode As System.Text.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1") Dim xmltw As New XmlTextWriter(SignedFileName, vencode)xmltw.Formatting = Formatting.Indented
xmlDigitalSignature.WriteTo(xmltw)
xmltw.Close()
ANY HELP!!!!!
Ernesto