greenter/xmldsig
PHP library for signing SUNAT electronic invoices in Peru. Load a PEM certificate and sign XML files or strings, adding the required ds:Signature block with transforms, digest and RSA signature to your comprobantes.
thegreenter/xmldsig) is highly specialized for SUNAT (Peruvian tax authority) electronic invoicing compliance, implementing XML-DSig (XML Digital Signatures). It remains a strong fit for Laravel applications issuing Peruvian e-invoicing (Factura Electrónica) or related fiscal documents.CONVERT.md). Misconfiguration risk persists..pem files must live in encrypted storage (e.g., Laravel storage/app/certs/ with encryption, or a secrets manager). No change.config/sunat.php) so developers cannot accidentally diverge per call site?composer.lock?thegreenter/* packages (e.g., greenter/core, greenter/xml)?.pem files be stored and rotated? (Unchanged — use encrypted storage or a secrets manager; no hardcoding.)SunatSigner wrapper service that binds algorithm configuration once:
// config/sunat.php
return [
'certificate' => env('SUNAT_CERT_PATH'),
'signature_algorithm' => 'RSA-SHA256',
'digest_algorithm' => 'SHA256',
];
class SunatSigner {
public function sign(string $xml): string {
$signer = new SignedXml();
$signer->setCertificate(Storage::disk('certs')->get(config('sunat.certificate')));
// Apply algorithm config here per v5.1.0 API
return $signer->signXml($xml);
}
}
InvoiceCreated; dispatch to a queue for batch workloads.composer.json to "thegreenter/xmldsig": "^5.1" and run composer update --dry-run to inspect transitive changes.config/sunat.php; never hardcode per call site.SunatSigner wrapper.DOMDocument/SimpleXML.Storage for certs; use Queues for large payloads.^5.1 and lock the resolved version; treat minor bumps as review-required given crypto-surface changes..pem in a secure vault (e.g., AWS KMS / Secrets Manager).try {
$signedXml = $signer->sign($xml);
Log::info('Invoice signed', ['invoice_id' => $id, 'alg' => config('sunat.signature_algorithm')]);
} catch (\Exception $e) {
Log::error('Signature failed', ['invoice_id' => $id, 'error' => $e->getMessage()]);
throw $e;
}
spomky-labs/php-xmlsecurity) if release cadence stalls again.How can I help you explore Laravel packages today?