-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Description
VB.net 2022:
I try to sign an XML but with an URI = Id whose value is numerical.
But "compute Signature" will not sign and generates an error:
System.Security.Cryptography.CryptographicException: Malformed reference element.
Certificado = New X509Certificate2(_CertArchivo, _CertContrasenia, X509KeyStorageFlags.Exportable)
xdTmp = New XmlDocument With {
.PreserveWhitespace = False
}
xdTmp.Load(xmlAFirmar)
sxTmp = New SignedXml(xdTmp) With {
.SigningKey = Certificado.GetRSAPrivateKey
}
sxTmp.SignedInfo.SignatureMethod = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
sxTmp.SignedInfo.CanonicalizationMethod = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
Dim ReferenceId As String = FindReferenceId(xdTmp)........'Call Function ReferenceID'
refTmp = New Reference With {
.Uri = "#" & ReferenceId
}
refTmp.AddTransform(New XmlDsigEnvelopedSignatureTransform)
refTmp.AddTransform(New XmlDsigC14NWithCommentsTransform)
sxTmp.AddReference(refTmp)
sxTmp.ComputeSignature()
Metadata
Metadata
Assignees
Labels
No labels