firmar XML

HMG en Español

Moderator: Rathinagiri

User avatar
IMATECH
Posts: 173
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.
Has thanked: 1 time
Been thanked: 3 times

Re: firmar XML

Post by IMATECH » Mon Sep 09, 2019 10:42 pm

Here you con find the code to sign a XML file using MS Capicom

https://github.com/JoseQuintas/sefazcla ... assina.prg

Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia

User avatar
edufloriv
Posts: 168
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB
Location: PERU
Has thanked: 8 times
Been thanked: 6 times

Post by edufloriv » Sat Sep 14, 2019 4:20 pm

Hola IMATECH,

Puse a prueba el código que gentilmente me pasaste, desafortunadamente se queda en la siguiente línea:

Code: Select all

   BEGIN SEQUENCE WITH __BreakBlock()

      cRetorno := "Erro Assinatura: Não carregado MSXML2.MXDigitalSignature.5.0"  //<--- ME LANZA ESTE ERROR
#ifdef __XHARBOUR__
      xmldsig := xhb_CreateObject( "MSXML2.MXDigitalSignature.5.0" )
#else
      xmldsig := win_OleCreateObject( "MSXML2.MXDigitalSignature.5.0" )
#endif
Parece que el problema es una incompatibilidad con Win-10

http://pctoledo.com.br/forum/viewtopic ... &start=15

¿ Hay forma de resolverlo ? - Mil gracias por su valioso tiempo.

-------------------------------------------------------------------------------------------------------------------------------------

Hi IMATECH,

I tested the code you graciously passed me, unfortunately it stays on the following line:

Code: Select all

   BEGIN SEQUENCE WITH __BreakBlock()

      cRetorno := "Erro Assinatura: Não carregado MSXML2.MXDigitalSignature.5.0"  //<--- THROW ME THIS ERROR
#ifdef __XHARBOUR__
      xmldsig := xhb_CreateObject( "MSXML2.MXDigitalSignature.5.0" )
#else
      xmldsig := win_OleCreateObject( "MSXML2.MXDigitalSignature.5.0" )
#endif
It seems that the problem is an incompatibility with Win-10
http://pctoledo.com.br/forum/viewtopic ... &start=15

Is there a way to solve it? - Thank you for your valuable time.

Eduardo Flores Rivas


LIMA - PERU

User avatar
IMATECH
Posts: 173
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.
Has thanked: 1 time
Been thanked: 3 times

Post by IMATECH » Sun Sep 15, 2019 4:42 am

HI Eduardo !

Looks you don't have "Microsoft XML Core Services 5.0" in your machine (it's part of MS Office 2003)

Are you using "File based Key" or "USB Token" ?
*The sign process can use Open SSL or WinCrypt (no MS Office needed)
MSXML 5.0 MSXML5 is a binary developed specifically for Microsoft Office. It originally shipped with Office 2003 and also ships with Office 2007. Microsoft has not released documentation for this version because Microsoft considers MSXML 5 an internal/integrated component of Office 2003. MSXML 5 is not included in Office 2010.
M., Ronaldo

By: IMATECH

Imation Tecnologia

User avatar
edufloriv
Posts: 168
Joined: Thu Nov 08, 2012 3:42 am
DBs Used: DBF, MariaDB
Location: PERU
Has thanked: 8 times
Been thanked: 6 times

Post by edufloriv » Mon Sep 16, 2019 1:22 pm

Hi Imatech,

I am using file based key, I have got : .CRT, .KEY, .PEM and .PFX files, I have tried with all these formats without result.

I have OpenSSL instaled on my computer. I must sign all the .XML file and these must be the result:

XML before sign:

Code: Select all

<ext:UBLExtensions>
    <ext:UBLExtension>
        <ext:ExtensionContent></ext:ExtensionContent>
    </ext:UBLExtension>
</ext:UBLExtensions>
XML after sign:

Code: Select all

<ext:UBLExtensions>
    <ext:UBLExtension>
        <ext:ExtensionContent>
            <ds:Signature Id="SignIMM">
                <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 URI="">
                    <ds:Transforms>
                        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                    </ds:Transforms>
                    <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                    <ds:DigestValue>IwJuNQGQaHmmm3iv2jj8JDv70Ow=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>
                nLaghokzMNrmrfPnbIg9b........wzZ2CgLTVjWQUAQ4wDAYDVQQIEwVNYWluZTE1UiLFwZXXXPUlf2o=
                </ds:SignatureValue>
                <ds:KeyInfo>
                    <ds:X509Data>
                        <ds:X509Certificate>
MIIFhzCCA3OgAwI......MIIEVDCCAzygAwIBAgIJAPTrkMJbCOr1MA0GCSqGSIb3DQEBBQUAMHkxCzAJBgNVBAYTAlVTVQQIEwVNYWluZTEgMOiRJ00nE=
                        </ds:X509Certificate>
                    </ds:X509Data>
                </ds:KeyInfo>
            </ds:Signature>
        </ext:ExtensionContent>
    </ext:UBLExtension>
</ext:UBLExtensions>
I would apreciate your help.

Best regards.

Eduardo Flores Rivas


LIMA - PERU

Post Reply