I need help.....
When I sign a XML, if I check the sign and the certificate with this function:
signedXml.CheckSignature(oCertificado, False)
the result is False and say me that the sign is valid but the certificate is not valid.
I don't know why is it. Do I need a special king of certificate?
Code:
0. Dim signedXml As New System.Security.Cryptography.Xml.SignedXml(documen tXML)
1. signedXml.SigningKey = oCertificado.PrivateKey
2. Dim reference As New System.Security.Cryptography.Xml.Reference()
3. reference.Uri = ""
4. reference.AddTransform(New XmlDsigEnvelopedSignatureTransform())
5. reference.AddTransform(New XmlDsigC14NTransform())
6. signedXml.AddReference(reference)
7. Dim KeyName As New KeyInfoName
8. KeyName.Value = "Public key of certificate"
9. Dim keyInfo As New KeyInfo
10. keyInfo.AddClause(KeyName)
11. keyInfo.AddClause(New RSAKeyValue(oCertificado.PublicKey.Key()))
12. keyInfo.AddClause(New KeyInfoX509Data(oCertificado))
13. signedXml.KeyInfo = keyInfo
14. signedXml.ComputeSignature()
My certificate is in CURRENT_USER\My and ASPNET have permiss for this certificate.
Thank you.