dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
23 #ifndef network_tlscontext_hpp
24 #define network_tlscontext_hpp
27 #include <openssl/bio.h>
28 #include <openssl/err.h>
29 #include <openssl/ossl_typ.h>
30 #include <openssl/ssl.h>
110 bool enableSNI =
true,
111 bool allowSANWildcards =
true );
158 const std::string& keyfile,
159 const std::string& passphrase );
168 const std::string &p12passphrase );
209 const std::string& capath );
274 bool allowSANWildcards );
285 static int pem_passwd_cb(
char *buf,
int size,
int rwflag,
void *userdata );
PeerVerification peerverficiation_
The peer verification method used.
static void ShutdownSSL()
Shutdown the SSL library.
@ tls1_3
TLS 1.3 disables SSLv2, SSLv3, TLS 1.0, TLS 1.1 and TLS 1.2.
TLSContext(const PeerVerification &peerverficiation=PeerVerification::pvVerifyFQDN, const TLSVersion &tlsversion=TLSVersion::tlsBest, bool enableSNI=true, bool allowSANWildcards=true)
Construct a TLS context.
static int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata)
Password callback, returns the passphrase set in the TLS context by the passphrase argument of loadCe...
bool enable_clr_
Enable / disable CRL (Certificate Revocation List) checking.
void setTrustPaths(const std::string &cafile, const std::string &capath)
Trust all certificates (PEM format) in the specified file and/or directory.
Interface to objects that support dumping their state to a string.
void construct(const PeerVerification &peerverficiation, const TLSVersion &tlsversion, bool enableSNI, bool allowSANWildcards)
Construct the TLSContext.
bool isSNIEnabled() const
Return true when SNI (server Name Information) is to be enabled by TLSSocket objects using this TLSCo...
@ pvVerifyNone
No peer verification - transmission is encrypted, peer is accepted even if peer certificate is invali...
static PeerVerification peerVerficiationFromString(const std::string &src)
Get a PeerVerfication enum from a string.
bool allow_san_wildcards_
Allow SAN names to match agains wildcards (eg foo.domain.org matches *.domain.org).
@ tls1_2
TLS 1.2 disables SSLv2, SSLv3, TLS 1.0 and TLS 1.1.
@ tls1_1
TLS 1.1 disables SSLv2, SSLv3 and TLS 1.0.
PeerVerification
The TLS peer verification method.
@ pvVerifyPeer
The peer must have a trusted certificate (unless a anonymous cipher is used).
std::string passphrase_
The passphrase to decrypt encrypted private keys (may be empty when the key is not encrypted).
PeerVerification getPeerVerification() const
Return the getPeerVerification mode.
void loadPEMIdentity(const std::string &certfile, const std::string &keyfile, const std::string &passphrase)
Load a certificate and the corresponding private key for an identity.
static void InitializeSSL()
Initialize the SSL library.
TLSVersion tlsversion_
The TLS version.
bool enable_sni_
Enable / disable SNI on TLSSocket objects using this TLSContext.
TLSVersion
The TLS version.
@ pvVerifyFQDN
As pvVerifyPeer, but the remote DNS name must match either the peer cert commonname or match one of t...
Interface for network communication.
void setCipherList(const std::string &cipherlist)
Set a list of ciphers, separated by a colon, the TLSContext will accept.
static TLSVersion tlsVersionFromString(const std::string &src)
Convert the src string to a TLSVersion or throw a common::Exception if that mapping fails.
SSL_CTX * tlsctx_
The openssl SSL_CTX.
long setOptions(long option)
Set SSL options.
void loadPKCS12(const std::string &p12file, const std::string &p12passphrase)
Loads a private key, matching certificate and optional CA certificates (eg a truststore) from a PKCS1...
SSL_CTX * getContext() const
Return a pointer to the SSL_CTX.
@ tlsBest
Use as default TLS version.
bool isAllowSANWildcards() const
If true, TLS will allow SAN wildcard matching.