mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
support custom ssl ctx configuration for SSLServer (#1073)
This commit is contained in:
parent
c384be02c9
commit
b80aa7fee3
2 changed files with 83 additions and 0 deletions
14
httplib.h
14
httplib.h
|
@ -1364,6 +1364,9 @@ public:
|
|||
SSLServer(X509 *cert, EVP_PKEY *private_key,
|
||||
X509_STORE *client_ca_cert_store = nullptr);
|
||||
|
||||
SSLServer(
|
||||
const std::function<bool(SSL_CTX &ssl_ctx)> &setup_ssl_ctx_callback);
|
||||
|
||||
~SSLServer() override;
|
||||
|
||||
bool is_valid() const override;
|
||||
|
@ -7105,6 +7108,17 @@ inline SSLServer::SSLServer(X509 *cert, EVP_PKEY *private_key,
|
|||
}
|
||||
}
|
||||
|
||||
inline SSLServer::SSLServer(
|
||||
const std::function<bool(SSL_CTX &ssl_ctx)> &setup_ssl_ctx_callback) {
|
||||
ctx_ = SSL_CTX_new(TLS_method());
|
||||
if (ctx_) {
|
||||
if (!setup_ssl_ctx_callback(*ctx_)) {
|
||||
SSL_CTX_free(ctx_);
|
||||
ctx_ = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline SSLServer::~SSLServer() {
|
||||
if (ctx_) { SSL_CTX_free(ctx_); }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue