FirmaSAT
10.50.0
|
SAT-related methods. More...
Public Types | |
enum class | KeyFormat { Binary = 0x0 , PEM = 0x10000 } |
Format for saved key files. More... | |
enum class | KeyOption { UnencryptedBase64 = 0x0 , EncryptedPEM = 0x10000 } |
Options for key output. More... | |
enum | SignOpts : unsigned int { Default = 0x0 , NoBOM = 0x2000 , UseEmptyElements = 0x20000 , BigFile = 0x8000000 , OverrideReqd = 0x4000 } |
Options for signing XML. More... | |
enum class | XmlOption { Strict = 0x0 , Loose = 0x4000 } |
Options for XML validation. More... | |
Static Public Member Functions | |
static std::string | Asciify (const std::string &xmlFile) |
Replace non-ASCII characters in an XML document with XML numeric character references (where permitted). More... | |
static int | CheckKeyAndCert (const std::string &keyFile, const std::string &password, const std::string &certFile) |
Verify that the public key in an X.509 certificate matches the private key. More... | |
static std::string | ExtractDigestFromSignature (const std::string &xmlFile, const std::string &certFile="") |
Extract message digest from the signature (sello) in an XML file . More... | |
static int | FixBOM (const std::string &outFile, const std::string &inputFile) |
Add UTF-8 byte order mark (BOM) to a file if not already present. More... | |
static std::string | GetCertAsString (const std::string &certFile) |
Get certificate data as a base64 string. More... | |
static std::string | GetKeyAsString (const std::string &keyFile, const std::string &password="", const KeyOption keyOpt=KeyOption::UnencryptedBase64) |
Get private key data as a base64 string. More... | |
static std::string | GetXmlAttribute (const std::string &xmlFile, const std::string &attributeName, const std::string &elementName) |
Extract attribute data from an XML file. More... | |
static int | InsertCert (const std::string &newFile, const std::string &xmlFile, const std::string &certFile) |
Insert certificate information into an XML document and output to a new file. More... | |
static std::string | InsertCertToString (const std::string &xmlFile, const std::string &certFile) |
Insert certificate information into an XML document and output to memory. More... | |
static std::string | MakeDigestFromXml (const std::string &xmlFile) |
Compute message digest of piped string (cadena) from an XML file. More... | |
static std::string | MakePipeStringFromXml (const std::string &xmlFile) |
Create the piped string (cadena) from an XML file. More... | |
static std::string | MakeSignatureFromXml (const std::string &xmlFile, const std::string &keyFile, const std::string &password="") |
Create signature as a base64 string from data in an XML file ready to be inserted as a sello node. More... | |
static int | NewKeyFile (const std::string &newFile, const std::string &newPassword, const std::string &keyFile, const std::string &keyPassword, const KeyFormat format=KeyFormat::Binary) |
Save keyfile with a new password. More... | |
static std::string | QueryCert (const std::string &certFile, const std::string &query) |
Query an X.509 certificate. More... | |
static void | SetXmlNoMatch (const std::string &value="") |
Modify the string returned when Sat::GetXmlAttribute fails to find a match. More... | |
static int | SignXml (const std::string &outFile, const std::string &xmlFile, const std::string &keyFile, const std::string &password="", const std::string &certFile="", const SignOpts signOpts=SignOpts::Default) |
Sign an XML file. More... | |
static std::string | SignXmlToString (const std::string &xmlFile, const std::string &keyFile, const std::string &password="", const std::string &certFile="", const SignOpts signOpts=SignOpts::Default) |
Sign an XML document and output to memory. More... | |
static std::string | Uuid () |
Generate a Universally Unique IDentifier (UUID) compliant with RFC 4122. More... | |
static int | ValidateXml (const std::string &xmlFile, const XmlOption xmlOpt=XmlOption::Strict) |
Validate an XML file against SAT specifications. More... | |
static int | VerifySignature (const std::string &xmlFile, const std::string &certFile="") |
Verify the signature (sello) in an XML file. More... | |
static int | WritePfxFile (const std::string &pfxFile, const std::string &pfxPassword, const std::string &keyFile, const std::string &keyPassword, const std::string &certFile) |
Create a PFX (PKCS-12) file in PEM format. More... | |
static std::string | XmlNoMatch () |
Error message returned when Sat::GetXmlAttribute fails to find a match. More... | |
static int | XmlReceiptVersion (const std::string &xmlFile) |
Find version number of Comprobante element or ID number for other document types. More... | |
SAT-related methods.
|
strong |
|
strong |
enum firmasat::Sat::SignOpts : unsigned int |
Options for signing XML.
|
strong |
|
static |
Replace non-ASCII characters in an XML document with XML numeric character references (where permitted).
xmlFile | Name of XML file (or a string containing XML data). |
"ó"
. Año="2016"
. In these cases, they are left as UTF-8-encoded characters.
|
static |
Verify that the public key in an X.509 certificate matches the private key.
keyFile | Name of private key file or string containing PEM representation. |
password | Password for encrypted private key. |
certFile | X.509 certificate file or XML document with embedded certificado node. |
|
static |
Extract message digest from the signature (sello) in an XML file .
xmlFile | Name of XML file to be processed (or a string containing XML data). |
certFile | Optional X.509 certificate file (will overrule public key in XML certificado node). |
|
static |
Add UTF-8 byte order mark (BOM) to a file if not already present.
outFile | Name of new file to be created. |
inputFile | Name of existing file. |
|
static |
Get certificate data as a base64 string.
certFile | X.509 certificate file or XML file with certificado node. |
|
static |
Get private key data as a base64 string.
keyFile | Private key file or key represented as a PEM string. |
password | Password for encrypted key. |
keyOpt | Options for key output. |
|
static |
Extract attribute data from an XML file.
xmlFile | Name of XML file to be processed (or a string containing XML data). |
attributeName | Name of attribute. |
elementName | Name of element or xpath expression (see remarks) |
std::runtime_error | if missing file or invalid XML. |
|
static |
Insert certificate information into an XML document and output to a new file.
newFile | Name of new output file to be created. |
xmlFile | Name of input XML file to be processed (or a string containing XML data). |
certFile | X.509 certificate file. |
|
static |
Insert certificate information into an XML document and output to memory.
xmlFile | Name of input XML file to be processed (or a string containing XML data). |
certFile | X.509 certificate file. |
|
static |
Compute message digest of piped string (cadena) from an XML file.
xmlFile | Name of XML file to be processed (or a string containing XML data). |
|
static |
Create the piped string (cadena) from an XML file.
xmlFile | Name of XML file to be processed (or a string containing XML data). |
|
static |
Create signature as a base64 string from data in an XML file ready to be inserted as a sello
node.
xmlFile | Name of base XML file to be signed (or a string containing XML data). |
keyFile | Name of private key file. |
password | Password for private key file. |
|
static |
Save keyfile with a new password.
newFile | Name of new output file to be created. |
newPassword | Password for new key file. |
keyFile | Name of input key file (or a string containing the key in PEM form). |
keyPassword | Password for existing key file. |
format | Format to save file (default = DER binary) |
|
static |
Query an X.509 certificate.
certFile | X.509 certificate file or XML file with certificado node. |
query | Query. |
yyyy-mm-ddThh:nn:ssZ
.
|
static |
Modify the string returned when Sat::GetXmlAttribute fails to find a match.
value | New string value. Pass "" to reset to default. |
|
static |
Sign an XML file.
outFile | Name of new signed file to be created |
xmlFile | Name of base XML file to be signed (or a string containing XML data). |
keyFile | Name of private key file. |
password | Password for private key file. |
certFile | (optional) name of X.509 certificate file to be included in output XML. |
signOpts | Options for output format. |
|
static |
Sign an XML document and output to memory.
xmlFile | Name of base XML file to be signed (or a string containing XML data). |
keyFile | Name of private key file (or string containing key data in PEM format). |
password | Password for private key file. |
certFile | (optional) name of X.509 certificate file to be included in output XML (or string containing certificate data in base64 or PEM format). |
signOpts | Options for output format. |
|
static |
Generate a Universally Unique IDentifier (UUID) compliant with RFC 4122.
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
where 'x' is a lowercase hexadecimal digit [0-9a-f].
|
static |
Validate an XML file against SAT specifications.
xmlFile | Name of XML file to be processed (or a string containing XML data). |
xmlOpt | Option for strict or loose XML restrictions. |
|
static |
Verify the signature (sello) in an XML file.
xmlFile | Name of XML file to be processed (or a string containing XML data). |
certFile | Optional X.509 certificate file. |
certificado
node in the XML will be used to verify the signature. However, if a certFile
is provided, the public key will be obtained from the specified X.509 certificate and any existing certificado
node in the XML will be ignored.
|
static |
Create a PFX (PKCS-12) file in PEM format.
pfxFile | Name of output PFX file to be created. |
pfxPassword | Password to open new PFX file. |
keyFile | Name of encrypted private key file. |
keyPassword | Password for encrypted private key file. |
certFile | Name of X.509 certificate file that matches private key. |
|
static |
Error message returned when Sat::GetXmlAttribute fails to find a match.
"!NO MATCH!"
)
|
static |
Find version number of Comprobante element or ID number for other document types.
xmlFile | Name of XML file to be processed (or a string containing XML data). |