dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
23 #ifndef network_x509cert_hpp
24 #define network_x509cert_hpp
28 #include <openssl/ssl.h>
29 #include <openssl/x509v3.h>
159 std::map<std::string,std::string>
other;
220 static X509_REQ*
loadPEM(
const std::string file );
226 static void free( X509_REQ* cert ) { X509_REQ_free( cert ); }
249 static std::string
getFingerPrint(
const X509_REQ *cert,
const std::string hashname =
"shake256" );
279 static X509*
loadPEM(
const std::string file );
285 static void free( X509* cert ) { X509_free( cert ); }
300 static std::string
getSerial(
const X509 *cert );
330 static std::string
getFingerPrint(
const X509 *cert,
const std::string hashname =
"shake256" );
343 static bool verifySAN(
const X509 *cert,
const SAN &san,
bool wildcards =
false );
354 static bool verifyName(
const std::string &peer,
const std::string &san,
bool wildcards =
false );
363 static bool verifyIP(
const std::string &peer,
const std::string &san );
Interface common to X509 documents.
static void free(X509_REQ *cert)
Free / clean an X509 object.
std::string state
The State or Province name.
Attributes that together constitute a X509 identity.
std::string serialNumber
A cert serial number.
static X509Type detectX509Type(const std::string file, std::string &tag)
Detects a X509 document type from a PEM file.
static std::string SANTypeAsString(const SANType &san_type)
Convert the SANType name to a string.
static void free(X509 *cert)
Free / clean an X509 object.
@ Certificate
Certificate PEM document.
static X509Common::Identity getIssuer(const X509 *cert)
Get the certificate issuer.
X509 Certificate signing request (CSR) interface.
static X509_REQ * loadPEM(const std::string file)
Load a certificate signing request (CSR) from a PEM file.
~X509Common()=delete
Never destruct, interface class.
static X509 * loadPEM(const std::string file)
Load a public key certificate (aka 'certificate') from a PEM file.
@ Unknown
Unknown PEM document.
static bool verifySAN(const X509 *cert, const SAN &san, bool wildcards=false)
Verify a peer name against this certificate's CN and SubjectAltnames.
X509Certificate()=delete
Never construct, interface class.
std::string organizationUnit
The organizational unit name.
@ stDNS
A DNS name such as myhost.mydomain.org.
std::string street
The street address.
X509CertificateSigningRequest()=delete
Never construct, interface class.
std::string businessCategory
The businessCategory.
static std::string getFingerPrint(const X509 *cert, const std::string hashname="shake256")
Get the certificate fingerprint (a hash on the public key modulus) in string format,...
@ stIP
An IPv4 or IPv6 address.
static Identity parseIdentity(const std::string src)
Parse a subject or issuer string into an Identity.
std::string countryCode
A two-character country code, for example NL for The Netherlands.
@ PublicKey
Public key PEM document.
std::string jurisdictionC
The jurisdiction country code.
std::string postalCode
The postal code.
X509Common()=delete
Never construct, interface class.
static X509Common::Identity getSubject(const X509 *cert)
Get the certificate subject identity.
X509 public key certificate (PKC) interface.
std::string jurisdictionST
The jurisdiction state.
static bool verifyIP(const std::string &peer, const std::string &san)
Verify a peer IP matches a SAN of type stIP.
SANType
The SubjectAltName type.
X509Common::SANType san_type
The type.
std::string organization
The organization name.
std::map< std::string, std::string > other
Other key-value pairs in the identity.
Interface for network communication.
@ stEMAIL
An email address.
static std::list< X509Common::SAN > getSubjectAltNames(const X509 *cert)
Get the SAN (subject alternate name) list for the certificate, which may be empty.
std::string locality
The locality name (city, town).
~X509Certificate()=delete
Never destruct, interface class.
std::string san_name
The name.
~X509CertificateSigningRequest()=delete
Never destruct, interface class.
static std::string getFingerPrint(const X509_REQ *cert, const std::string hashname="shake256")
Get the certificate fingerprint (a hash on the public key modulus) in string format,...
static std::string getSerial(const X509 *cert)
Get the certificate serial number as concatenated hex bytes.
@ CertificateSigningRequest
CSR PEM document.
static X509Common::Identity getSubject(const X509_REQ *cert)
Get the CSR subject identity.
std::string commonName
The common name.
std::string email
The email address.
@ PrivateKey
Private key PEM document (possibly encrypted).
X509Type
Enumeration of X509 document types.
static bool verifyName(const std::string &peer, const std::string &san, bool wildcards=false)
Verify a peer name matches a SAN.