25#ifndef JOIN_CRYPTO_TLS_CONTEXT_HPP
26#define JOIN_CRYPTO_TLS_CONTEXT_HPP
141#if OPENSSL_VERSION_NUMBER >= 0x30000000L
147 int setCurve (
const std::string& curves);
161 SSL_CTX*
handle () const noexcept;
167 bool verify () const noexcept;
173 int depth () const noexcept;
187 static const SSL_METHOD* method (
Role role) noexcept;
189#if OPENSSL_VERSION_NUMBER < 0x30000000L
195 static DH* getDh2236 ();
202 bool _verify =
false;
TLS/DTLS context.
Definition tls_context.hpp:42
int setCaFile(const std::string &caFile)
set the location of the trusted CA certificate file.
Definition tls_context.cpp:179
void setVerify(bool verify, int depth=-1) noexcept
enable or disable peer certificate verification.
Definition tls_context.cpp:202
bool isServer() const noexcept
check if the role is a server role.
Definition tls_context.cpp:340
int setCertificate(const std::string &cert, const std::string &key="") noexcept
set the certificate and the private key.
Definition tls_context.cpp:120
int setAlpnProtocols(const std::vector< std::string > &protocols)
set the ALPN protocols list.
Definition tls_context.cpp:277
bool verify() const noexcept
check if peer verification is enabled.
Definition tls_context.cpp:322
TlsContext() noexcept=default
create an empty context, unable to negotiate.
int setCipher(const std::string &cipher) noexcept
set the cipher list (TLSv1.2 and below).
Definition tls_context.cpp:212
SSL_CTX * handle() const noexcept
get the native SSL_CTX handle.
Definition tls_context.cpp:313
int setCipher_1_3(const std::string &cipher) noexcept
set the cipher list (TLSv1.3).
Definition tls_context.cpp:233
Role
TLS/DTLS role.
Definition tls_context.hpp:48
@ DtlsClient
Definition tls_context.hpp:51
@ TlsClient
Definition tls_context.hpp:49
@ DtlsServer
Definition tls_context.hpp:52
@ TlsServer
Definition tls_context.hpp:50
int depth() const noexcept
get the maximum certificate chain depth.
Definition tls_context.cpp:331
int setCaPath(const std::string &caPath)
set the location of the trusted CA certificates.
Definition tls_context.cpp:156
const std::string key(65, 'a')
key.
Definition acceptor.hpp:32
std::shared_ptr< SSL_CTX > SslCtxPtr
Definition openssl.hpp:240