libdigidocpp 4.1.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 |
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<typename Func > | |
string | toString (Func func, 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.
|
explicit |
Creates copy of the OpenSSL X509 certificate.
cert | X509 certificate structure to be wrapped. |
Creates X509 certificate from bytes.
bytes | X509 certificate in bytes. |
format | Format input bytes format |
Exception | throws exception if X509 certificate parsing failed. |
|
inlineexplicit |
|
defaultnoexcept |
Move constructor.
|
default |
Copy constructor.
|
default |
Clean up underlying X509 data.
vector< string > X509Cert::certificatePolicies | ( | ) | const |
Returns current certificate policies
X509 * X509Cert::handle | ( | ) | const |
Returns certificate internal handle (OpenSSL X509 struct)
Referenced by digidoc::Signer::method().
bool X509Cert::isCA | ( | ) | const |
Rerturns true if certificate is CA
Referenced by digidoc::PKCS11Signer::cert().
string X509Cert::issuerName | ( | const std::string & | obj = std::string() | ) | const |
Returns issuer name as string.
obj | if set to empty string then returns whole issuer name. Otherwise, for example, if set to CN then returns Common name part from issuer name. |
Exception | exception is throws if the conversion failed. |
bool X509Cert::isValid | ( | time_t * | t = nullptr | ) | const |
Validates if certificate is in valid time slot
t | If param is 0 then current time is used, else defined time |
Referenced by digidoc::PKCS11Signer::cert().
vector< X509Cert::KeyUsage > X509Cert::keyUsage | ( | ) | const |
Returns current certificate key usage bits
Referenced by digidoc::PKCS11Signer::cert().
X509Cert::operator bool | ( | ) | const |
Returns true if handle is valid
X509Cert::operator std::vector< unsigned char > | ( | ) | const |
Encodes the X509 certificate using DER encoding.
Referenced by operator==().
bool X509Cert::operator! | ( | ) | const |
Negative operator to check if object is valid
bool X509Cert::operator!= | ( | const X509Cert & | other | ) | const |
Not equal operator to compare two objects
References operator==().
bool X509Cert::operator== | ( | const X509Cert & | other | ) | const |
Equal operator to compare two objects
References operator std::vector< unsigned char >().
bool X509Cert::operator== | ( | X509 * | other | ) | const |
Equal operator to compare two objects
References operator==().
Referenced by operator!=(), and operator==().
vector< string > X509Cert::qcStatements | ( | ) | const |
Return QCStatements info https://www.ietf.org/rfc/rfc3739.txt
References QC_QCT, and QC_SYNTAX2.
string X509Cert::serial | ( | ) | const |
Returns X.509 certificate serial number.
Exception | exception is thrown if the serial is incorrect. |
string X509Cert::subjectName | ( | const std::string & | obj = std::string() | ) | const |
Return subject name as string.
obj | empty string then returns whole issuer name. Otherwise, for example, if set to CN then returns Common name part from issuer name. |
Exception | exception is throws if the conversion failed. |
Referenced by digidoc::Signature::signedBy().
string digidoc::X509Cert::toString | ( | Func | func, |
const string & | obj | ||
) | const |
Converts X509_NAME struct to string.
func | X509_NAME struct that is converted to string. |
obj | Optional parameter to get from X509_NAME (default CN). |
Exception | throws exception if conversion failed. |
|
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 |
https://www.ietf.org/rfc/rfc3739.txt - id-etsi-qcs-QcType
Referenced by qcStatements().
|
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 |
|
static |
|
static |