Signer facade provides convenient methods to create invoice signers. The signing implementation uses XAdES-EPES format compliant with the Spanish FacturaE signing policy v3.1.
Signer Facade
TheSigner class is a convenience facade for creating signer instances.
pfx()
Create a signer from a PKCS#12 certificate file (.pfx or .p12).Path to the PKCS#12 certificate file
Certificate passphrase (optional)
Returns a Pkcs12Signer instance
pem()
Create a signer from PEM-encoded certificate and private key files.Path to the PEM certificate file
Path to the PEM private key file
Private key passphrase (optional)
Returns a Pkcs12Signer instance
Pkcs12Signer
ThePkcs12Signer class implements XAdES-EPES digital signatures for FacturaE documents.
Static Constructors
pfx()
Create signer from a PKCS#12 file.Path to the PKCS#12 certificate file
Certificate passphrase (optional)
Returns a Pkcs12Signer instance
If certificate file not found or cannot be read
pem()
Create signer from PEM-encoded certificate and key files.Path to the PEM certificate file
Path to the PEM private key file
Private key passphrase (optional)
Returns a Pkcs12Signer instance
If certificate or key file not found or cannot be read
timestamp()
Add timestamp authority (TSA) to the signature for long-term validity.TSA endpoint URL (RFC 3161 compliant)
TSA username for authentication (optional)
TSA password for authentication (optional)
Returns self for method chaining
sign()
Sign a FacturaE XML document.XML string of the invoice to sign
Returns the signed XML string with XAdES-EPES signature
If XML parsing fails or signature generation fails
This method is typically called automatically when using
Invoice::toXml() or Invoice::export() if a signer has been set via Invoice::sign().InvoiceSigner Interface
All signers implement theInvoiceSigner interface:
Signature Details
ThePkcs12Signer generates:
- XAdES-EPES signatures (advanced electronic signatures with explicit policy)
- Enveloped signature format (signature included within the signed document)
- FacturaE policy v3.1 compliance
- SHA-256 digest algorithm
- RSA-SHA256 signature algorithm
- Optional RFC 3161 timestamps for long-term validity
Signature Policy
The signer uses the official FacturaE signing policy:- Policy Name: Política de Firma FacturaE v3.1
- Policy URL: http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf
- Policy Digest (SHA-1):
Ohixl6upD6av8N7pEvDABhEL6hM=
Complete Example
Timestamp Authorities
Some free TSA services you can use:- FreeTSA:
https://freetsa.org/tsr - Sectigo:
http://timestamp.sectigo.com - DigiCert:
http://timestamp.digicert.com