|
Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
|
Server TLS settings: certificates (with SNI) and ALPN. More...
#include <TlsContext.hpp>

Public Member Functions | |
| TlsContext (const std::string &cert_file, const std::string &key_file, config::HttpVersion http_version) | |
| TlsContext (const config::TlsCertificate &default_cert, std::vector< config::TlsCertificate > sni_certs, config::HttpVersion http_version) | |
| ~TlsContext () | |
| TlsContext (const TlsContext &)=delete | |
| TlsContext & | operator= (const TlsContext &)=delete |
| SSL_CTX * | get () const |
| config::HttpVersion | get_http_version () const |
| bool | reload (std::string *error=nullptr) |
| Re-reads every certificate and key file. Thread-safe. | |
| bool | files_changed () const |
| True if a certificate or key file changed since it was last loaded. | |
| std::string | certificate_for (const std::string &server_name) const |
The certificate file that serves server_name (for tests and logs). | |
| void | configure (SSL_CTX *ctx) |
| Configures a context to match this one (protocol floor, ALPN). | |
Private Member Functions | |
| std::shared_ptr< const CertSet > | current () const |
| std::string | file_stamp () const |
Static Private Member Functions | |
| static int | servername_cb (SSL *ssl, int *alert, void *arg) |
Private Attributes | |
| SSL_CTX * | ctx_ {nullptr} |
| config::HttpVersion | http_version_ {config::HttpVersion::Http1_1} |
| config::TlsCertificate | default_cert_ |
| std::vector< config::TlsCertificate > | sni_certs_ |
| std::mutex | mutex_ |
| std::shared_ptr< const CertSet > | certs_ |
| std::string | stamp_ |
Server TLS settings: certificates (with SNI) and ALPN.
get() returns one SSL_CTX for the server's lifetime. During each handshake a servername callback moves the connection to the context holding the certificate for the requested name, so certificates can be chosen by SNI and replaced (reload()) without touching that SSL_CTX.
| orbit::network::TlsContext::TlsContext | ( | const std::string & | cert_file, |
| const std::string & | key_file, | ||
| config::HttpVersion | http_version | ||
| ) |
| orbit::network::TlsContext::TlsContext | ( | const config::TlsCertificate & | default_cert, |
| std::vector< config::TlsCertificate > | sni_certs, | ||
| config::HttpVersion | http_version | ||
| ) |
| default_cert | Served when no SNI certificate matches the name. |
| sni_certs | Chosen by the DNS names in each one's subjectAltName (or CN). |
| orbit::network::TlsContext::~TlsContext | ( | ) |
|
delete |
| std::string orbit::network::TlsContext::certificate_for | ( | const std::string & | server_name | ) | const |
The certificate file that serves server_name (for tests and logs).
| void orbit::network::TlsContext::configure | ( | SSL_CTX * | ctx | ) |
Configures a context to match this one (protocol floor, ALPN).
|
private |
|
private |
| bool orbit::network::TlsContext::files_changed | ( | ) | const |
True if a certificate or key file changed since it was last loaded.
|
inline |
|
inline |
|
delete |
| bool orbit::network::TlsContext::reload | ( | std::string * | error = nullptr | ) |
Re-reads every certificate and key file. Thread-safe.
New handshakes use the new certificates; established connections are unaffected. If any file fails to load, the current certificates stay.
| error | Receives the reason on failure. |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |