MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / SSLServer

Method SSLServer

external/httplib.h:9025–9058  ·  view source on GitHub ↗

SSL HTTP server implementation

Source from the content-addressed store, hash-verified

9023
9024// SSL HTTP server implementation
9025inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path,
9026 const char *client_ca_cert_file_path,
9027 const char *client_ca_cert_dir_path,
9028 const char *private_key_password) {
9029 ctx_ = SSL_CTX_new(TLS_server_method());
9030
9031 if (ctx_) {
9032 SSL_CTX_set_options(ctx_,
9033 SSL_OP_NO_COMPRESSION |
9034 SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
9035
9036 SSL_CTX_set_min_proto_version(ctx_, TLS1_2_VERSION);
9037
9038 if (private_key_password != nullptr && (private_key_password[0] != '\0')) {
9039 SSL_CTX_set_default_passwd_cb_userdata(
9040 ctx_,
9041 reinterpret_cast<void *>(const_cast<char *>(private_key_password)));
9042 }
9043
9044 if (SSL_CTX_use_certificate_chain_file(ctx_, cert_path) != 1 ||
9045 SSL_CTX_use_PrivateKey_file(ctx_, private_key_path, SSL_FILETYPE_PEM) !=
9046 1 ||
9047 SSL_CTX_check_private_key(ctx_) != 1) {
9048 SSL_CTX_free(ctx_);
9049 ctx_ = nullptr;
9050 } else if (client_ca_cert_file_path || client_ca_cert_dir_path) {
9051 SSL_CTX_load_verify_locations(ctx_, client_ca_cert_file_path,
9052 client_ca_cert_dir_path);
9053
9054 SSL_CTX_set_verify(
9055 ctx_, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
9056 }
9057 }
9058}
9059
9060inline SSLServer::SSLServer(X509 *cert, EVP_PKEY *private_key,
9061 X509_STORE *client_ca_cert_store) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected