Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML: ¿Es posible firmar solo el contenido del elemento raíz? #408

Open
underdpt opened this issue Aug 23, 2024 · 0 comments
Open

XML: ¿Es posible firmar solo el contenido del elemento raíz? #408

underdpt opened this issue Aug 23, 2024 · 0 comments

Comments

@underdpt
Copy link

Hola a todos,

Estoy implementando la firma para un nuevo servicio de la DGT, y en la documentación aparece que no se firma el nodo raíz del fichero xml, sino el sub-nodo <Datos_Firmados>. ¿Esto es posible hacerlo con autofirma?

Un ejemplo de fichero firmado sería:

<?xml version="1.0" encoding="UTF-8"?>
<Solicitud_Registro_Entrada>
    <Datos_Firmados>
        <Datos_Genericos>
            <Remitente>
                <Nombre>MANIPULADOR</Nombre>
                <Apellidos>DE PLACAS</Apellidos>
                <Documento_Identificacion>
                    <Tipo>1</Tipo>
                    <Numero>DELETED</Numero>
                </Documento_Identificacion>
                <Correo_Electronico/>
            </Remitente>
            <Interesados/>
            <Asunto>
                <Codigo>OBCT</Codigo>
                <Descripcion>Operaciones Basicas de Gestion de Custodia Virtual de tarjetas eITV</Descripcion>
            </Asunto>
            <Destino>
                <Codigo>101001</Codigo>
                <Descripcion>DGT - Vehículos</Descripcion>
            </Destino>
        </Datos_Genericos>
        <Datos_Especificos>
            <operaciones>
                <operacion>
                    <codigoOperacion>EEFF_ALTA_INSCRIPCION_PLACAS_WS</codigoOperacion>
                    <datos>
                        <vehiculo>
                            <matricula>DELETED</matricula>
                            <bastidor>DELETED</bastidor>
                        </vehiculo>
                        <compradorplaca>
                            <dni>DELETED</dni>
                            <nombreApellidos>Plaquiforme</nombreApellidos>
                            <extranjero>No</extranjero>
                        </compradorplaca>
                        <expedicion>
                            <doifabricante>DELETED</doifabricante>
                            <numManipulador>Kurrupipi</numManipulador>
                            <numHomologacion/>
                            <numPlacasexpedir>5</numPlacasexpedir>
                            <fechaCompra>21/01/2022</fechaCompra>
                            <observaciones>Plaquetas 05</observaciones>
                        </expedicion>
                    </datos>
                </operacion>
            </operaciones>
        </Datos_Especificos>
    </Datos_Firmados>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-9da60454-7628-4ebe-ab2c-58690999aa31-Signature">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
            <ds:Reference Id="Reference-ce4ce2c2-33a5-4d0b-bcec-1b7477738d6c" URI="">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                    <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
                        <ds:XPath>not(ancestor-or-self::ds:Signature)</ds:XPath>
                    </ds:Transform>
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
                <ds:DigestValue>B39ZTd1oybevaJGJ5gAfgeHBR9pD9XgCS3kS65V+geeqTnd/1Y6OqN5TLRCMFa4d7mV9GwEPCowvoh94kAIj6g==</ds:DigestValue>
            </ds:Reference>
            <ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#Signature-9da60454-7628-4ebe-ab2c-58690999aa31-SignedProperties">
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
                <ds:DigestValue>Gff8tbppOY0wVyxImMj9qetO64BjEgMr+JVyOZ2UOd8gVzv4qbnhQL0hfBRMUwj/JGFD1i5iLbIzeXALjzEgBA==</ds:DigestValue>
            </ds:Reference>
            <ds:Reference URI="#Signature-9da60454-7628-4ebe-ab2c-58690999aa31-KeyInfo">
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
                <ds:DigestValue>uFd4AVHIscXaQQqA883SE/NCIElh2dybmoFq11q9BnbZ1yNIiTlKNqknP8LGIiq5DisztWaofOQmzgNYcSjBEA==</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue Id="Signature-9da60454-7628-4ebe-ab2c-58690999aa31-SignatureValue">
            dXf3Hpw2a/MsxmGpIgIbWRmgeMp18mf3yK7mPgJUlRcT2pO8XtSVy+WQmyulDHV16KUPVMbRXLV1puPZcbLWeyJNdRZt+77AX8C5hudwmKtwWmiWAEAcFPv3E//cTRZ9bxyWfB66F8LrAKdvcHQRTnAoZCniK+x7rLdl1kWpKMa2QE7qVAN+BV12lDjByrbUoIfEQfkwY0J2GGJkxHmU2LJlbucUYVxGBPe6lL+ydMIH4k8jvuWsjpCOG0aLIsFC4JBhw9b+onoqxRijYzLDWHHIWHagwWdd5gVl9OwpZ9a38ygV60/zYLURmgaYwutOyEtqmJbtyWdaZYj+tmx0KQ==
        </ds:SignatureValue>
        <ds:KeyInfo Id="Signature-9da60454-7628-4ebe-ab2c-58690999aa31-KeyInfo">
            <ds:X509Data>
                <ds:X509Certificate>
                    DELETED
                </ds:X509Certificate>
                <ds:X509Certificate>
                     DELETED
                </ds:X509Certificate>
                <ds:X509Certificate>
                    DELETED
                </ds:X509Certificate>
            </ds:X509Data>
            <ds:KeyValue>
                <ds:RSAKeyValue>
                    <ds:Modulus>
                        DELETED
                    </ds:Modulus>
                    <ds:Exponent>AQAB</ds:Exponent>
                </ds:RSAKeyValue>
            </ds:KeyValue>
        </ds:KeyInfo>
        <ds:Object>
            <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#"
                                        Id="Signature-9da60454-7628-4ebe-ab2c-58690999aa31-QualifyingProperties"
                                        Target="#Signature-9da60454-7628-4ebe-ab2c-58690999aa31-Signature">
                <xades:SignedProperties Id="Signature-9da60454-7628-4ebe-ab2c-58690999aa31-SignedProperties">
                    <xades:SignedSignatureProperties>
                        <xades:SigningTime>2022-01-24T09:33:58+01:00</xades:SigningTime>
                        <xades:SigningCertificate>
                            <xades:Cert>
                                <xades:CertDigest>
                                    <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>                           <ds:DigestValue>Br+Id8Ou01FmK+UekIaO5D4euvRdzz0AtlU1wmnSXoVMT5GxcxQx2ES4D11w7pC4fjbE6kAl2Mi3+1MXXXV4vQ==
                                    </ds:DigestValue>
                                </xades:CertDigest>
                                <xades:IssuerSerial>
                                    <ds:X509IssuerName>CN=DELETED
                                        L=DELETED
                                    </ds:X509IssuerName>
                                    <ds:X509SerialNumber>DELETED</ds:X509SerialNumber>
                                </xades:IssuerSerial>
                            </xades:Cert>
                        </xades:SigningCertificate>
                    </xades:SignedSignatureProperties>
                    <xades:SignedDataObjectProperties>
                        <xades:DataObjectFormat ObjectReference="#Reference-ce4ce2c2-33a5-4d0b-bcec-1b7477738d6c">
                            <xades:Description/>
                            <xades:ObjectIdentifier>
                                <xades:Identifier Qualifier="OIDAsURN">urn:oid:1.2.840.10003.5.109.10</xades:Identifier>
                                <xades:Description/>
                            </xades:ObjectIdentifier>
                            <xades:MimeType>text/xml</xades:MimeType>
                            <xades:Encoding/>
                        </xades:DataObjectFormat>
                    </xades:SignedDataObjectProperties>
                </xades:SignedProperties>
            </xades:QualifyingProperties>
        </ds:Object>
    </ds:Signature>
</Solicitud_Registro_Entrada>

Gracias!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant