Skip to content

About signing an XML #2

Description

@cano-hernan

Hi, friends.
I am going to describe you the XML Signature for my country:

It will get the completed sign for our XMLs this way:

        <ext:UBLExtension>
            <ext:ExtensionContent>
                <ds:Signature Id="xmldsig-dabce243-e835-47a3-aa57-4f097778df74" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:SignedInfo>
                        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                        <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                        <ds:Reference Id="xmldsig-dabce243-e835-47a3-aa57-4f097778df74-ref0" URI="">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>**xxxDIGESTVALUE_DEL_XML_ANTES_DE_FIRMARxxx**</ds:DigestValue>
                        </ds:Reference>
                        <ds:Reference URI="#xmldsig-dabce243-e835-47a3-aa57-4f097778df74-keyinfo">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>**xxxDIGESTVALUE_DE_KEYINFOxxx**</ds:DigestValue>
                        </ds:Reference>
                        <ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#xmldsig-dabce243-e835-47a3-aa57-4f097778df74-signedprops">
                            <ds:Transforms>
                                <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                            </ds:Transforms>
                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                            <ds:DigestValue>**xxxDIGESTVALUE_DE_SIGNEDPROPERTIESxxx**</ds:DigestValue>
                        </ds:Reference>
                    </ds:SignedInfo>
                    <ds:SignatureValue Id="xmldsig-dabce243-e835-47a3-aa57-4f097778df74-sigvalue">xxxDIGESTVALUE_DE_SIGNEDINFOxxx</ds:SignatureValue>
                    <ds:KeyInfo Id="xmldsig-dabce243-e835-47a3-aa57-4f097778df74-keyinfo" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        <ds:X509Data>
                            <ds:X509Certificate>**xxxCERTIFICADO_EN_BASE64xxx**</ds:X509Certificate>
                        </ds:X509Data>
                    </ds:KeyInfo>
                    <ds:Object>
                        <xades:QualifyingProperties Target="#xmldsig-dabce243-e835-47a3-aa57-4f097778df74" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#">
                            <xades:SignedProperties Id="xmldsig-dabce243-e835-47a3-aa57-4f097778df74-signedprops">
                                <xades:SignedSignatureProperties>
                                    <xades:SigningTime>2023-10-18T04:29:10.809Z</xades:SigningTime>
                                    <xades:SigningCertificate>
                                        <xades:Cert>
                                            <xades:CertDigest>
                                                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                                                <ds:DigestValue>**xxxDIGESTVALUE_DEL_CERTIFICADOxxx**</ds:DigestValue>
                                            </xades:CertDigest>
                                            <xades:IssuerSerial>
                                                <ds:X509IssuerName>**xxxDATO_EN_EL_CERTIFICADOxxx**</ds:X509IssuerName>
                                                <ds:X509SerialNumber>**xxxDATO_TAMBIEN_EN_EL_CERTIFICADOxxx**</ds:X509SerialNumber>
                                            </xades:IssuerSerial>
                                        </xades:Cert>
                                    </xades:SigningCertificate>
                                    <xades:SignaturePolicyIdentifier>
                                        <xades:SignaturePolicyId>
                                            <xades:SigPolicyId>
                                                <xades:Identifier>https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf</xades:Identifier>
                                            </xades:SigPolicyId>
                                            <xades:SigPolicyHash>
                                                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                                                <ds:DigestValue>dMoMvtcG5aIzgYo0tIsSQeVJBDnUnfSOfBpxXrmor0Y=</ds:DigestValue>
                                            </xades:SigPolicyHash>
                                        </xades:SignaturePolicyId>
                                    </xades:SignaturePolicyIdentifier>
                                    <xades:SignerRole>
                                        <xades:ClaimedRoles>
                                            <xades:ClaimedRole>supplier</xades:ClaimedRole>
                                        </xades:ClaimedRoles>
                                    </xades:SignerRole>
                                </xades:SignedSignatureProperties>
                            </xades:SignedProperties>
                        </xades:QualifyingProperties>
                    </ds:Object>
                </ds:Signature>
            </ext:ExtensionContent>
        </ext:UBLExtension>
    </ext:UBLExtensions>

Los datos necesarios son (mostrados en el orden en que aparecen en el XML):

xxxDIGESTVALUE_DEL_XML_ANTES_DE_FIRMARxxx
xxxDIGESTVALUE_DE_KEYINFOxxx
xxxDIGESTVALUE_DE_SIGNEDPROPERTIESxxx
xxxCERTIFICADO_EN_BASE64xxx
xxxDIGESTVALUE_DEL_CERTIFICADOxxx

Y los debo calcular en el sgte orden:

xxxCERTIFICADO_EN_BASE64xxx ----------------------- puedo calcularlo
xxxDIGESTVALUE_DEL_CERTIFICADOxxx ----------------- puedo calcularlo

xxxDIGESTVALUE_DEL_XML_ANTES_DE_FIRMARxxx --------- ¿cómo lo calculo con 'VFP XML Library Set'?
xxxDIGESTVALUE_DE_KEYINFOxxx   -------------------- ¿cómo lo calculo con 'VFP XML Library Set'?
xxxDIGESTVALUE_DE_SIGNEDPROPERTIESxxx ------------- ¿cómo lo calculo con 'VFP XML Library Set'?

¿Cómo calculo los DigestValue con 'VFP XML Library Set'?

Gracias.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions