Async 1.8.0
|
A class representing an X.509 certificate. More...
#include <AsyncSslX509.h>
Public Types | |
enum | : long { VERSION_1 = 0 , VERSION_2 = 1 , VERSION_3 = 2 } |
Public Member Functions | |
SslX509 (void) | |
Default constructor. | |
SslX509 (X509 *cert, bool managed=true) | |
Constructor. | |
SslX509 (X509_STORE_CTX &ctx) | |
Constructor. | |
SslX509 (SslX509 &&other) | |
Move constructor. | |
SslX509 & | operator= (SslX509 &&other) |
Move assignment operator. | |
SslX509 (const SslX509 &)=delete | |
Don't allow copy construction. | |
~SslX509 (void) | |
Constructor taking PEM data. | |
void | set (X509 *cert, bool managed=true) |
Set the internal X509 object to use. | |
void | clear (void) |
Set this object to empty. | |
bool | isNull (void) const |
Check if this object is empty. | |
SslX509 & | operator= (const SslX509 &)=delete |
Disallow use of the copy assignment operator. | |
bool | setIssuerName (const X509_NAME *name) |
Set the issuer distinguished name. | |
const X509_NAME * | issuerName (void) const |
Get the issuer distinguished name. | |
bool | setSubjectName (const X509_NAME *name) |
Set the subject distinguished name. | |
const X509_NAME * | subjectName (void) const |
Get the subject distinguished name. | |
operator const X509 * (void) const | |
Cast to an OpenSSL X509 pointer. | |
std::string | commonName (void) const |
Get the common name of the subject. | |
bool | verify (SslKeypair &keypair) |
Verify that this certificate is signed by the given key. | |
bool | readPem (const std::string &pem) |
Initialize this certificate from a string containing PEM data. | |
std::string | pem (void) const |
Get this certificate as PEM data. | |
bool | readPemFile (const std::string &filename) |
Initialize this object with PEM data read from given file. | |
bool | writePemFile (FILE *f) |
Write this certificate to file in PEM format. | |
bool | writePemFile (const std::string &filename) |
Write this certificate to file in PEM format. | |
bool | appendPemFile (const std::string &filename) |
Append this certificate to file in PEM format. | |
bool | setVersion (long version) |
Set the version of this certificate. | |
long | version (void) const |
Get the version of this certificate. | |
void | setNotBefore (std::time_t in_time) |
Set the date and time from which this certificate is valid. | |
std::time_t | notBefore (void) const |
Get the date and time from which this certificate is valid. | |
std::string | notBeforeString (void) const |
Get the date and time from which this certificate is valid. | |
std::string | notBeforeLocaltimeString (void) const |
Get the date and time from which this certificate is valid. | |
void | setNotAfter (std::time_t in_time) |
Set the date and time up to which this certificate is valid. | |
std::time_t | notAfter (void) const |
Get the date and time up to which this certificate is valid. | |
std::string | notAfterString (void) const |
Get the date and time up to which this certificate is valid. | |
std::string | notAfterLocaltimeString (void) const |
Get the date and time up to which this certificate is valid. | |
void | setValidityTime (unsigned days, int offset_days=0) |
Set the validity time relative to current time. | |
void | validityTime (int &days, int &seconds) const |
The duration that this certificate is valid. | |
bool | timeIsWithinRange (std::time_t tbegin=time(NULL), std::time_t tend=time(NULL)) const |
Check if the certificate is valid within the given range. | |
int | signatureType (void) const |
Get the signature type. | |
void | setSerialNumber (long serial_number=-1) |
Set the serial number of the certificate. | |
std::string | serialNumberString (void) const |
Get the serial number as a string. | |
void | addIssuerName (const std::string &field, const std::string &value) |
Add a name to the issuer distinguished name. | |
void | addSubjectName (const std::string &field, const std::string &value) |
Add a name to the subject distinguished name. | |
std::string | issuerNameString (void) const |
Get the issuer distinguished name as a string. | |
std::string | subjectNameString (void) const |
Get the subject distinguished name as a string. | |
void | addExtensions (const SslX509Extensions &exts) |
Add v3 extensions to this certificate. | |
SslKeypair | publicKey (void) const |
Get the public key @retrun Returns the public key. | |
bool | setPublicKey (SslKeypair &pkey) |
Set the public key for this certificate. | |
bool | sign (SslKeypair &pkey) |
Sign this certificate using the given key. | |
std::vector< unsigned char > | digest (void) const |
Get the digest of this certificate. | |
bool | matchHost (const std::string &name) const |
Check if the given hostname match this certificate. | |
bool | matchIp (const IpAddress &ip) const |
Check if the given IP address match this certificate. | |
void | print (const std::string &prefix="") const |
Print this certificate to std::cout. | |
A class representing an X.509 certificate.
Definition at line 123 of file AsyncSslX509.h.
anonymous enum : long |
Enumerator | |
---|---|
VERSION_1 | |
VERSION_2 | |
VERSION_3 |
Definition at line 126 of file AsyncSslX509.h.
|
inline |
Default constructor.
Definition at line 136 of file AsyncSslX509.h.
|
inline |
Constructor.
cert | A pointer to an existing OpenSSL X509 object |
managed | If true, the pointer will be freed on destruction |
Definition at line 146 of file AsyncSslX509.h.
|
inlineexplicit |
Constructor.
ctx | An OpenSSL X509_STORE_CTX |
Get the current certificate from the given store context. The returned pointer will be used as the data container in this object but will not be freed on dustruction since the store context is assumed to own the certificate.
Definition at line 161 of file AsyncSslX509.h.
|
inline |
Move constructor.
other | The object to move from |
Definition at line 173 of file AsyncSslX509.h.
References set().
|
delete |
Don't allow copy construction.
|
inline |
Constructor taking PEM data.
pem | The PEM data to parse into a CSR object |
Destructor
Definition at line 224 of file AsyncSslX509.h.
References set().
|
inline |
Add v3 extensions to this certificate.
exts | Add the given extensions to this certificate |
Definition at line 814 of file AsyncSslX509.h.
|
inline |
Add a name to the issuer distinguished name.
field | The name of the DN field to set |
value | The value to set the DN field to |
Definition at line 711 of file AsyncSslX509.h.
|
inline |
Add a name to the subject distinguished name.
field | The name of the DN field to set |
value | The value to set the DN field to |
Definition at line 734 of file AsyncSslX509.h.
|
inline |
Append this certificate to file in PEM format.
filename | The path to the file to append PEM data to |
Definition at line 467 of file AsyncSslX509.h.
References writePemFile().
|
inline |
Set this object to empty.
The internal OpenSSL X509 object will be freed if it's managed by this object.
Definition at line 251 of file AsyncSslX509.h.
|
inline |
Get the common name of the subject.
Definition at line 337 of file AsyncSslX509.h.
References subjectName().
|
inline |
Get the digest of this certificate.
Definition at line 859 of file AsyncSslX509.h.
Referenced by print().
|
inline |
Check if this object is empty.
Definition at line 264 of file AsyncSslX509.h.
Referenced by print().
|
inline |
Get the issuer distinguished name.
Definition at line 293 of file AsyncSslX509.h.
Referenced by issuerNameString().
|
inline |
Get the issuer distinguished name as a string.
Definition at line 756 of file AsyncSslX509.h.
References issuerName().
Referenced by print().
|
inline |
Check if the given hostname match this certificate.
name | The hostname to match against |
Definition at line 889 of file AsyncSslX509.h.
|
inline |
Check if the given IP address match this certificate.
ip | The IP address to match against |
Definition at line 900 of file AsyncSslX509.h.
References Async::IpAddress::toString().
|
inline |
Get the date and time up to which this certificate is valid.
Definition at line 554 of file AsyncSslX509.h.
Referenced by notAfterLocaltimeString().
|
inline |
Get the date and time up to which this certificate is valid.
Definition at line 584 of file AsyncSslX509.h.
References notAfter().
Referenced by print().
|
inline |
Get the date and time up to which this certificate is valid.
Definition at line 568 of file AsyncSslX509.h.
|
inline |
Get the date and time from which this certificate is valid.
Definition at line 503 of file AsyncSslX509.h.
Referenced by notBeforeLocaltimeString().
|
inline |
Get the date and time from which this certificate is valid.
Definition at line 533 of file AsyncSslX509.h.
References notBefore().
Referenced by print().
|
inline |
Get the date and time from which this certificate is valid.
Definition at line 517 of file AsyncSslX509.h.
|
inline |
Cast to an OpenSSL X509 pointer.
Definition at line 331 of file AsyncSslX509.h.
Disallow use of the copy assignment operator.
Move assignment operator.
other | The object to move from |
Definition at line 191 of file AsyncSslX509.h.
References set().
|
inline |
Get this certificate as PEM data.
Definition at line 397 of file AsyncSslX509.h.
Referenced by readPem().
|
inline |
Print this certificate to std::cout.
prefix | A prefix to add to each printed row |
Definition at line 910 of file AsyncSslX509.h.
References digest(), isNull(), issuerNameString(), notAfterLocaltimeString(), notBeforeLocaltimeString(), serialNumberString(), subjectNameString(), and Async::SslX509ExtSubjectAltName::toString().
|
inline |
Get the public key @retrun Returns the public key.
Definition at line 827 of file AsyncSslX509.h.
|
inline |
Initialize this certificate from a string containing PEM data.
pem | The PEM data |
Definition at line 380 of file AsyncSslX509.h.
References pem().
|
inline |
Initialize this object with PEM data read from given file.
filename | The path to the file to read PEM data from |
Definition at line 415 of file AsyncSslX509.h.
|
inline |
Get the serial number as a string.
Definition at line 677 of file AsyncSslX509.h.
Referenced by print().
|
inline |
Set the internal X509 object to use.
cert | A pointer to an existing OpenSSL X509 object |
managed | Set to true to free the X509 object on destruction |
Definition at line 235 of file AsyncSslX509.h.
Referenced by operator=(), SslX509(), and ~SslX509().
|
inline |
Set the issuer distinguished name.
name | A pointer to an already existing X509_NAME OpenSSL object |
Definition at line 276 of file AsyncSslX509.h.
|
inline |
Set the date and time up to which this certificate is valid.
in_time | The time as seconds since the Unix epoch |
Definition at line 545 of file AsyncSslX509.h.
Referenced by setValidityTime().
|
inline |
Set the date and time from which this certificate is valid.
in_time | The time as seconds since the Unix epoch |
Definition at line 494 of file AsyncSslX509.h.
Referenced by setValidityTime().
|
inline |
Set the public key for this certificate.
pkey | The public key to set |
Definition at line 838 of file AsyncSslX509.h.
|
inline |
Set the serial number of the certificate.
serial_number | The serial number to set |
If no serial number is given, it will be randomized.
Definition at line 657 of file AsyncSslX509.h.
|
inline |
Set the subject distinguished name.
name | A pointer to an already existing X509_NAME OpenSSL object |
Definition at line 304 of file AsyncSslX509.h.
|
inline |
Set the validity time relative to current time.
days | The number of days this certificate should be valid |
offset_days | The number of days to offset from current time |
Definition at line 597 of file AsyncSslX509.h.
References setNotAfter(), and setNotBefore().
|
inline |
Set the version of this certificate.
version | The version that this certificate adheres to |
Ex: setVersion(Async::SslX509::VERSION_3)
Definition at line 479 of file AsyncSslX509.h.
References version().
|
inline |
Sign this certificate using the given key.
pkey | The key to sign with |
Definition at line 848 of file AsyncSslX509.h.
|
inline |
Get the signature type.
See the documentation for the OpenSSL X509_get_signature_type function for more information.
Definition at line 646 of file AsyncSslX509.h.
|
inline |
Get the subject distinguished name.
Definition at line 321 of file AsyncSslX509.h.
Referenced by commonName(), and subjectNameString().
|
inline |
Get the subject distinguished name as a string.
Definition at line 785 of file AsyncSslX509.h.
References subjectName().
Referenced by print().
|
inline |
Check if the certificate is valid within the given range.
tbegin | The earliest time the certificate must be valid |
tend | The latest time the certificate must be valid |
Definition at line 628 of file AsyncSslX509.h.
|
inline |
The duration that this certificate is valid.
days | Return the number of days of validity |
seconds | Return the number of additional seconds of validity |
Definition at line 615 of file AsyncSslX509.h.
|
inline |
Verify that this certificate is signed by the given key.
keypair | The key to check against |
Definition at line 369 of file AsyncSslX509.h.
|
inline |
Get the version of this certificate.
Definition at line 488 of file AsyncSslX509.h.
Referenced by setVersion().
|
inline |
Write this certificate to file in PEM format.
filename | The path to the file to write PEM data to |
Definition at line 457 of file AsyncSslX509.h.
References writePemFile().
|
inline |
Write this certificate to file in PEM format.
f | An open file to write data to |
Definition at line 438 of file AsyncSslX509.h.
Referenced by appendPemFile(), and writePemFile().