Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error Compute Signature VB2022 #341

Copy link
Copy link
@aldodomingo2610

Description

@aldodomingo2610
Issue body actions

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()
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.