none
Prefijos en Firmas Electronicas en .NET RRS feed

  • Pregunta

  • Buenas, Alguien Estoy desarrollando una aplicación en VB.NET para Firma Electrónicas, pero el Formato que genera .NET es la siguiente:

    <Signature >

    ...

    <\Signature>

    y lo que neceque tenga el prefijo "ds":

    <ds:Signature >

    ...

    <\ds:Signature>

    Este es mi código:

    Public Sub SignXmlFile(ByVal FileName As String, ByVal SignedFileName As String, ByVal Key As String, ByVal Pass As String) Dim Certificado As New X509Certificate2(Key,Pass) Dim doc As New XmlDocument()

    doc.PreserveWhitespace = False doc.Load(New XmlTextReader(FileName))

    Dim signedXml As New SignedXml(doc)

    signedXml.SigningKey = Certificado.PrivateKey signedXml.SignedInfo.CanonicalizationMethod = signedXml.XmlDsigExcC14NWithCommentsTransformUrl

    Dim canMethod As XmlDsigExcC14NWithCommentsTransform =

    CType(signedXml.SignedInfo.CanonicalizationMethodObject, XmlDsigExcC14NWithCommentsTransform)

    canMethod.InclusiveNamespacesPrefixList = "Signer" Dim reference As New Reference() reference.Uri = "" Dim env As New XmlDsigEnvelopedSignatureTransform(True) reference.AddTransform(env) signedXml.AddReference(reference) Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(CType(Certificado.PrivateKey, RSA))) signedXml.KeyInfo = keyInfo signedXml.ComputeSignature() Dim xmlDigitalSignature As XmlElement = signedXml.GetXml()

    doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, True)) if TypeOf doc.FirstChild Is XmlDeclaration Then doc.RemoveChild(doc.FirstChild) End If Dim xmltw As New XmlTextWriter(SignedFileName, New UTF8Encoding(False)) doc.WriteTo(xmltw) End Sub

    miércoles, 9 de octubre de 2013 17:16

Todas las respuestas