Add client certificate support

This commit is contained in:
Vitaliy Filippov
2026-04-03 21:22:42 +03:00
parent 7d9124b63a
commit ff225534f1
7 changed files with 30 additions and 1 deletions
+6
View File
@@ -47,6 +47,8 @@ struct http_co_t
int request_timeout = 0;
bool ssl = false;
std::string ssl_cert;
std::string ssl_key;
std::string ssl_ca;
std::string host;
std::string request;
@@ -392,6 +394,10 @@ void http_co_t::start_connection()
? !SSL_CTX_load_verify_locations(ssl_ctx, ssl_ca.c_str(), NULL)
: !SSL_CTX_set_default_verify_paths(ssl_ctx))
goto init_err;
if (ssl_cert != "" && ssl_key != "" &&
(!SSL_CTX_use_certificate_file(ssl_ctx, ssl_cert.c_str(), SSL_FILETYPE_PEM) ||
!SSL_CTX_use_PrivateKey_file(ssl_ctx, ssl_key.c_str(), SSL_FILETYPE_PEM)))
goto init_err;
}
ssl_bio = BIO_new(BIO_s_socket());
if (!ssl_bio)