2017 © Pedro Peláez
 

library xmldsig

Herramienta para Firmar XML segun normativa de SUNAT para Facturación Electrónica

image

gsalas/xmldsig

Herramienta para Firmar XML segun normativa de SUNAT para Facturación Electrónica

  • Monday, May 29, 2017
  • by giansalex
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 18 Forks
  • 1 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

XmlDSig - Greenter

Travis-CI Codacy Badge, (*1)

Esta libreria se emplea para firmar comprobantes electrónicos según las normas de SUNAT., (*2)

Se requiere el certificado en formato .PEM, puede utilizar el siguiente ejemplo para convertir el certificado .PFX al otros formatos., (*3)

Instalar:

Empleando composer desde packagist., (*4)

composer require greenter/xmldsig

Ejemplo


use Greenter\XMLSecLibs\Sunat\SignedXml; require 'vendor/autoload.php'; $xmlPath = '20600995805-01-F001-1.xml'; $certPath = 'certifcate.pem'; // Antes convertir pfx -> pem (private+certificate keys) $signer = new SignedXml(); $signer->setCertificateFromFile($certPath); // or $signer->setCertificate('-----BEGIN RSA PRIVATE KEY-----.....'); $xmlSigned = $signer->signFromFile($xmlPath); // or $signer->signXml('<Invoice>....'); file_put_contents("signed.xml", $xmlSigned);

Resultado:, (*5)

Antes:, (*6)

<ext:UBLExtensions>
    <ext:UBLExtension>
        <ext:ExtensionContent></ext:ExtensionContent>
    </ext:UBLExtension>
</ext:UBLExtensions>

Despues:, (*7)

<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>

The Versions

29/05 2017

dev-master

9999999-dev https://github.com/giansalex/xmldsig/

Herramienta para Firmar XML segun normativa de SUNAT para Facturación Electrónica

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by Giancarlos Salas

xml security signature xmldsig sunat

22/05 2017

v2.1.1

2.1.1.0 https://github.com/giansalex/xmldsig/

Herramienta para Firmar XML segun normativa de SUNAT para Facturación Electrónica

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by Giancarlos Salas

xml security signature xmldsig sunat

01/02 2016

v2.1.0

2.1.0.0 https://github.com/Maks3w/xmldsig/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

15/08 2015

v2.0.0

2.0.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

22/05 2015

v1.1.0

1.1.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

06/11 2014

v1.0.1

1.0.1.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

12/12 2013

v1.0

1.0.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

12/12 2013

0.3.1

0.3.1.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

05/11 2013

v0.3

0.3.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

11/04 2013

v0.2

0.2.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig

16/12 2012

v0.1

0.1.0.0 https://github.com/Maks3w/

Tool for easy management of XML Signatures (http://www.w3.org/TR/xmldsig-core/)

  Sources   Download

BSD-2-Clause

The Requires

  • cdatazone/xmlseclibs *

 

The Development Requires

by Avatar Maks3w

xml security signature soap xmldsig