TLS/DTLS context.
More...
#include <tls_context.hpp>
|
| | TlsContext () noexcept=default |
| | create an empty context, unable to negotiate.
|
| |
| | TlsContext (Role role) |
| | create TLS/DTLS context for the given role.
|
| |
| | TlsContext (const TlsContext &)=default |
| | copy constructor.
|
| |
| TlsContext & | operator= (const TlsContext &)=default |
| | copy assignment operator.
|
| |
| | TlsContext (TlsContext &&)=default |
| | move constructor.
|
| |
| TlsContext & | operator= (TlsContext &&)=default |
| | move assignment operator.
|
| |
| | ~TlsContext ()=default |
| | destroy instance.
|
| |
| int | setCertificate (const std::string &cert, const std::string &key="") noexcept |
| | set the certificate and the private key.
|
| |
| int | setCaPath (const std::string &caPath) |
| | set the location of the trusted CA certificates.
|
| |
| int | setCaFile (const std::string &caFile) |
| | set the location of the trusted CA certificate file.
|
| |
| void | setVerify (bool verify, int depth=-1) noexcept |
| | enable or disable peer certificate verification.
|
| |
| int | setCipher (const std::string &cipher) noexcept |
| | set the cipher list (TLSv1.2 and below).
|
| |
| int | setCipher_1_3 (const std::string &cipher) noexcept |
| | set the cipher list (TLSv1.3).
|
| |
| int | setAlpnProtocols (const std::vector< std::string > &protocols) |
| | set the ALPN protocols list.
|
| |
| SSL_CTX * | handle () const noexcept |
| | get the native SSL_CTX handle.
|
| |
| bool | verify () const noexcept |
| | check if peer verification is enabled.
|
| |
| int | depth () const noexcept |
| | get the maximum certificate chain depth.
|
| |
| bool | isServer () const noexcept |
| | check if the role is a server role.
|
| |
◆ Role
TLS/DTLS role.
| Enumerator |
|---|
| TlsClient | TLS client.
|
| TlsServer | TLS server.
|
| DtlsClient | DTLS client.
|
| DtlsServer | DTLS server.
|
◆ TlsContext() [1/4]
| join::TlsContext::TlsContext |
( |
| ) |
|
|
defaultnoexcept |
create an empty context, unable to negotiate.
◆ TlsContext() [2/4]
| TlsContext::TlsContext |
( |
Role | role | ) |
|
|
explicit |
create TLS/DTLS context for the given role.
- Parameters
-
| role | client or server, TLS or DTLS. |
- Exceptions
-
| std::runtime_error | if SSL_CTX_new fails. |
◆ TlsContext() [3/4]
| join::TlsContext::TlsContext |
( |
const TlsContext & | | ) |
|
|
default |
copy constructor.
- Parameters
-
| other | other object to copy. |
◆ TlsContext() [4/4]
move constructor.
- Parameters
-
| other | other object to move. |
◆ ~TlsContext()
| join::TlsContext::~TlsContext |
( |
| ) |
|
|
default |
◆ depth()
| int TlsContext::depth |
( |
| ) |
const |
|
noexcept |
get the maximum certificate chain depth.
- Returns
- depth.
◆ handle()
| SSL_CTX * TlsContext::handle |
( |
| ) |
const |
|
noexcept |
get the native SSL_CTX handle.
- Returns
- SSL_CTX*.
◆ isServer()
| bool TlsContext::isServer |
( |
| ) |
const |
|
noexcept |
check if the role is a server role.
- Returns
- true if the role is a server role, false otherwise.
◆ operator=() [1/2]
copy assignment operator.
- Parameters
-
| other | other object to assign. |
- Returns
- assigned object.
◆ operator=() [2/2]
move assignment operator.
- Parameters
-
| other | other object to assign. |
- Returns
- assigned object.
◆ setAlpnProtocols()
| int TlsContext::setAlpnProtocols |
( |
const std::vector< std::string > & | protocols | ) |
|
set the ALPN protocols list.
- Parameters
-
| protocols | list of protocol names (e.g. {"h2", "http/1.1"}). |
- Returns
- 0 on success, -1 on failure.
◆ setCaFile()
| int TlsContext::setCaFile |
( |
const std::string & | caFile | ) |
|
set the location of the trusted CA certificate file.
- Parameters
-
| caFile | path of the trusted CA certificate file. |
- Returns
- 0 on success, -1 on failure.
◆ setCaPath()
| int TlsContext::setCaPath |
( |
const std::string & | caPath | ) |
|
set the location of the trusted CA certificates.
- Parameters
-
| caPath | path of the trusted CA certificates. |
- Returns
- 0 on success, -1 on failure.
◆ setCertificate()
| int TlsContext::setCertificate |
( |
const std::string & | cert, |
|
|
const std::string & | key = "" ) |
|
noexcept |
set the certificate and the private key.
- Parameters
-
| cert | certificate path. |
| key | private key path. |
- Returns
- 0 on success, -1 on failure.
◆ setCipher()
| int TlsContext::setCipher |
( |
const std::string & | cipher | ) |
|
|
noexcept |
set the cipher list (TLSv1.2 and below).
- Parameters
-
- Returns
- 0 on success, -1 on failure.
◆ setCipher_1_3()
| int TlsContext::setCipher_1_3 |
( |
const std::string & | cipher | ) |
|
|
noexcept |
set the cipher list (TLSv1.3).
- Parameters
-
- Returns
- 0 on success, -1 on failure.
◆ setVerify()
| void TlsContext::setVerify |
( |
bool | verify, |
|
|
int | depth = -1 ) |
|
noexcept |
enable or disable peer certificate verification.
- Parameters
-
| verify | true to enable peer verification. |
| depth | maximum certificate chain depth (-1 = no limit). |
◆ verify()
| bool TlsContext::verify |
( |
| ) |
const |
|
noexcept |
check if peer verification is enabled.
- Returns
- true if enabled.
The documentation for this class was generated from the following files: