PHP code example of greenter / xmldsig
1. Go to this page and download the library: Download greenter/xmldsig library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
greenter / xmldsig example snippets
use Greenter\XMLSecLibs\Sunat\SignedXml;
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);