dodo  0.0.1
A C++ library to create containerized Linux services
dodo::network::X509CertificateSigningRequest Class Reference

X509 Certificate signing request (CSR) interface. More...

#include <x509cert.hpp>

Inheritance diagram for dodo::network::X509CertificateSigningRequest:
Collaboration diagram for dodo::network::X509CertificateSigningRequest:

Static Public Member Functions

static void free (X509_REQ *cert)
 Free / clean an X509 object. More...
 
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, multiple hexadecimal bytes values separated by a colon. More...
 
static X509Common::Identity getSubject (const X509_REQ *cert)
 Get the CSR subject identity. More...
 
static X509_REQ * loadPEM (const std::string file)
 Load a certificate signing request (CSR) from a PEM file. More...
 
- Static Public Member Functions inherited from dodo::network::X509Common
static X509Type detectX509Type (const std::string file, std::string &tag)
 Detects a X509 document type from a PEM file. More...
 
static std::string SANTypeAsString (const SANType &san_type)
 Convert the SANType name to a string. More...
 

Private Member Functions

 X509CertificateSigningRequest ()=delete
 Never construct, interface class. More...
 
 ~X509CertificateSigningRequest ()=delete
 Never destruct, interface class. More...
 

Additional Inherited Members

- Public Types inherited from dodo::network::X509Common
enum  SANType { SANType::stDNS = GEN_DNS, SANType::stURI = GEN_URI, SANType::stEMAIL = GEN_EMAIL, SANType::stIP = GEN_IPADD }
 The SubjectAltName type. More...
 
enum  X509Type {
  X509Type::Unknown, X509Type::PrivateKey, X509Type::PublicKey, X509Type::CertificateSigningRequest,
  X509Type::Certificate
}
 Enumeration of X509 document types. More...
 
- Static Protected Member Functions inherited from dodo::network::X509Common
static Identity parseIdentity (const std::string src)
 Parse a subject or issuer string into an Identity. More...
 

Detailed Description

X509 Certificate signing request (CSR) interface.

Note that this is an interface class, it does not manage ownership of X509_REQ structures.

See Secure sockets for details on the role of this class.

Definition at line 205 of file x509cert.hpp.

Constructor & Destructor Documentation

◆ X509CertificateSigningRequest()

dodo::network::X509CertificateSigningRequest::X509CertificateSigningRequest ( )
privatedelete

Never construct, interface class.

◆ ~X509CertificateSigningRequest()

dodo::network::X509CertificateSigningRequest::~X509CertificateSigningRequest ( )
privatedelete

Never destruct, interface class.

Member Function Documentation

◆ free()

static void dodo::network::X509CertificateSigningRequest::free ( X509_REQ *  cert)
inlinestatic

Free / clean an X509 object.

Parameters
certThe X509_REQ object to free.

Definition at line 226 of file x509cert.hpp.

◆ getFingerPrint()

std::string dodo::network::X509CertificateSigningRequest::getFingerPrint ( const X509_REQ *  cert,
const std::string  hashname = "shake256" 
)
static

Get the certificate fingerprint (a hash on the public key modulus) in string format, multiple hexadecimal bytes values separated by a colon.

openssl list -digest-algorithms shows a full list of hash (digest) names. Stick to newer hash algorithms from the SHA-3 family.

Exceptions
common::Exceptionif the digest name is invalid.
See also
https://en.wikipedia.org/wiki/Secure_Hash_Algorithms
Parameters
certA pointer to the X509 certificate.
hashnameThe name of the hash algorithm to use. Defaults to 'shake256'. Names are case-insensitive.
Returns
A string representation of the fingerprint.

Definition at line 121 of file x509cert.cpp.

References dodo::common::getSSLErrors(), and throw_Exception.

Here is the call graph for this function:

◆ getSubject()

X509Common::Identity dodo::network::X509CertificateSigningRequest::getSubject ( const X509_REQ *  cert)
static

Get the CSR subject identity.

Parameters
certThe source CSR / X509_REQ.
Returns
the CSR subject identity.

Definition at line 112 of file x509cert.cpp.

References dodo::common::bio2String(), and dodo::network::X509Common::parseIdentity().

Here is the call graph for this function:

◆ loadPEM()

X509_REQ * dodo::network::X509CertificateSigningRequest::loadPEM ( const std::string  file)
static

Load a certificate signing request (CSR) from a PEM file.

The X509_REQ object pointed to gets owned by the caller and must be freed with free( X509_REQ* cert ). Note that the call will fail if the file is not a CSR, even if it is a valid PEM file - such as a certificate or a private key in PEM format.

Parameters
fileThe filename to load from.
Exceptions
common::Exceptionwhen the openSSL BIO fails to create.
common::Exceptionwhen the file cannot be read.
common::Exceptionwhen the file is not a valid PEM file.
Returns
Pointer to your X509_REQ.

Definition at line 92 of file x509cert.cpp.

References dodo::common::getSSLErrors(), and throw_Exception.

Here is the call graph for this function:

The documentation for this class was generated from the following files: