|
libdigidocpp 4.4.0
|
Wrapper for OpenSSL X509 certificate structure. More...
#include <X509Cert.h>
Public Types | |
| enum | Format { Der , Pem } |
| enum | KeyUsage { DigitalSignature = 0 , NonRepudiation , KeyEncipherment , DataEncipherment , KeyAgreement , KeyCertificateSign , CRLSign , EncipherOnly , DecipherOnly } |
Public Member Functions | |
| X509Cert (X509 *cert=nullptr) | |
| X509Cert (const unsigned char *bytes, size_t size, Format format=Der) | |
| X509Cert (const std::vector< unsigned char > &bytes, Format format=Der) | |
| X509Cert (std::initializer_list< unsigned char > bytes, Format format=Der) | |
| X509Cert (const std::string &path, Format format=Pem) | |
| X509Cert (X509Cert &&other) noexcept | |
| X509Cert (const X509Cert &other) | |
| ~X509Cert () | |
| std::string | serial () const |
| std::string | issuerName (const std::string &obj=std::string()) const |
| std::string | subjectName (const std::string &obj=std::string()) const |
| std::vector< KeyUsage > | keyUsage () const |
| std::vector< std::string > | certificatePolicies () const |
| std::vector< std::string > | qcStatements () const |
| bool | isCA () const |
| bool | isValid (time_t *t=nullptr) const |
| bool | verify (bool noqscd, tm validation_time={}) const |
| X509 * | handle () const |
| operator std::vector< unsigned char > () const | |
| X509Cert & | operator= (const X509Cert &other) |
| X509Cert & | operator= (X509Cert &&other) noexcept |
| operator bool () const | |
| bool | operator! () const |
| bool | operator== (X509 *other) const |
| bool | operator== (const X509Cert &other) const |
| bool | operator!= (const X509Cert &other) const |
| template<auto Func> | |
| string | toString (const string &obj) const |
Static Public Attributes | |
| static const std::string | QC_COMPLIANT = "0.4.0.1862.1.1" |
| static const std::string | QC_SSCD = "0.4.0.1862.1.4" |
| static const std::string | QC_QCP = "0.4.0.1862.1.5" |
| static const std::string | QC_QCT = "0.4.0.1862.1.6" |
| static const std::string | QC_SYNTAX1 = "1.3.6.1.5.5.7.11.1" |
| static const std::string | QC_SYNTAX2 = "1.3.6.1.5.5.7.11.2" |
| static const std::string | QCS_NATURAL = "0.4.0.194121.1.1" |
| static const std::string | QCS_LEGAL = "0.4.0.194121.1.2" |
| static const std::string | QCT_ESIGN = "0.4.0.1862.1.6.1" |
| static const std::string | QCT_ESEAL = "0.4.0.1862.1.6.2" |
| static const std::string | QCT_WEB = "0.4.0.1862.1.6.3" |
| static const std::string | QCP_PUBLIC_WITH_SSCD = "0.4.0.1456.1.1" |
| static const std::string | QCP_PUBLIC = "0.4.0.1456.1.2" |
| static const std::string | QCP_NATURAL = "0.4.0.194112.1.0" |
| static const std::string | QCP_LEGAL = "0.4.0.194112.1.1" |
| static const std::string | QCP_NATURAL_QSCD = "0.4.0.194112.1.2" |
| static const std::string | QCP_LEGAL_QSCD = "0.4.0.194112.1.3" |
| static const std::string | QCP_WEB = "0.4.0.194112.1.4" |
Wrapper for OpenSSL X509 certificate structure.
Key usage bits defined in certificate
|
explicit |
Creates copy of the OpenSSL X509 certificate.
| cert | OpenSSL X509 certificate structure to be wrapped. |
Creates X509 certificate from a vector of bytes.
| bytes | X509 certificate data. |
| format | Format input bytes format (Der or Pem). |
| Exception | if X509 certificate parsing failed. |
|
inlineexplicit |
|
defaultnoexcept |
Move constructor.
|
default |
Copy constructor.
|
default |
Clean up underlying OpenSSL X509 data.
| vector< string > X509Cert::certificatePolicies | ( | ) | const |
Returns the certificate's policy OIDs.
| X509 * X509Cert::handle | ( | ) | const |
Returns the internal OpenSSL X509 structure handle.
Referenced by digidoc::Signer::method().
| bool X509Cert::isCA | ( | ) | const |
Checks if the certificate is a Certificate Authority (CA).
Referenced by digidoc::PKCS11Signer::cert().
| string X509Cert::issuerName | ( | const std::string & | obj = std::string() | ) | const |
Returns issuer name as an RFC 2253 string.
| obj | If empty, returns the full issuer DN. If a short name (e.g., "CN", "O", "C") is provided, returns only that component of the issuer name. |
| Exception | if the conversion failed. |
| bool X509Cert::isValid | ( | time_t * | t = nullptr | ) | const |
Validates if the certificate is within its valid time period.
| t | Pointer to time_t. If nullptr, the current system time is used. |
t. | Exception | if validation fails. |
Referenced by digidoc::PKCS11Signer::cert().
| vector< X509Cert::KeyUsage > X509Cert::keyUsage | ( | ) | const |
Returns the certificate's key usage bits.
KeyUsage enums. Referenced by digidoc::PKCS11Signer::cert().
| X509Cert::operator bool | ( | ) | const |
Checks if the certificate object holds a valid OpenSSL handle.
| X509Cert::operator std::vector< unsigned char > | ( | ) | const |
Encodes the X509 certificate using DER encoding.
| bool X509Cert::operator! | ( | ) | const |
Checks if the certificate object is invalid (holds no handle).
| bool X509Cert::operator!= | ( | const X509Cert & | other | ) | const |
Compares two X509Cert objects for inequality.
| other | Another X509Cert object. |
References operator==().
| bool X509Cert::operator== | ( | const X509Cert & | other | ) | const |
Compares two X509Cert objects.
| other | Another X509Cert object. |
References operator==().
| bool X509Cert::operator== | ( | X509 * | other | ) | const |
Compares the certificate with an OpenSSL X509 pointer.
| other | Pointer to OpenSSL X509 structure. |
Referenced by operator!=(), and operator==().
| vector< string > X509Cert::qcStatements | ( | ) | const |
Returns Qualified Certificate (QC) statements as defined in RFC 3739 and ETSI EN 319 412-5.
References QC_QCT, and QC_SYNTAX2.
| string X509Cert::serial | ( | ) | const |
Returns X.509 certificate serial number in decimal string format.
| Exception | if the serial number cannot be retrieved. |
| string X509Cert::subjectName | ( | const std::string & | obj = std::string() | ) | const |
Returns subject name as an RFC 2253 string.
| obj | If empty, returns the full subject DN. If a short name (e.g., "CN", "SN", "GN") is provided, returns only that component of the subject name. |
| Exception | if the conversion failed. |
Referenced by digidoc::Signature::signedBy().
| string digidoc::X509Cert::toString | ( | const string & | obj | ) | const |
Converts OpenSSL X509_NAME struct to string.
| obj | Optional parameter to extract a specific component (e.g., "CN"). |
| Exception | if conversion failed. |
| bool X509Cert::verify | ( | bool | noqscd, |
| tm | validation_time = {} |
||
| ) | const |
Verifies if the certificate is signed by a trusted issuer.
| noqscd | If true, QSCD (Qualified Signature Creation Device) requirements are not checked. |
| validation_time | Time at which the validation is performed. |
| Exception | if verification error occurs. |
|
static |
https://www.ietf.org/rfc/rfc3739.txt - id-etsi-qcs-QcCompliance
|
static |
https://www.ietf.org/rfc/rfc3739.txt - id-etsi-qcs-QcPDS
|
static |
|
static |
https://www.ietf.org/rfc/rfc3739.txt - id-etsi-qcs-QcSSCD
|
static |
https://www.ietf.org/rfc/rfc3739.txt - id-qcs-pkixQCSyntax-v1
|
static |
https://www.ietf.org/rfc/rfc3739.txt - id-qcs-pkixQCSyntax-v2
Referenced by qcStatements().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
http://www.etsi.org/deliver/etsi_en/319400_319499/31941201/01.01.01_60/en_31941201v010101p.pdf - id-etsi-qcs-semanticsId-legal
|
static |
http://www.etsi.org/deliver/etsi_en/319400_319499/31941201/01.01.01_60/en_31941201v010101p.pdf - id-etsi-qcs-semanticsId-natural
|
static |
http://www.etsi.org/deliver/etsi_en/319400_319499/31941205/02.01.01_60/en_31941205v020101p.pdf - id-etsi-qct-eseal
|
static |
http://www.etsi.org/deliver/etsi_en/319400_319499/31941205/02.01.01_60/en_31941205v020101p.pdf - id-etsi-qct-esign
|
static |
http://www.etsi.org/deliver/etsi_en/319400_319499/31941205/02.01.01_60/en_31941205v020101p.pdf - id-etsi-qct-web