-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix #2217 #2218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2217 #2218
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1546,7 +1546,7 @@ class ClientImpl { | |
| #ifdef CPPHTTPLIB_OPENSSL_SUPPORT | ||
| void set_ca_cert_path(const std::string &ca_cert_file_path, | ||
| const std::string &ca_cert_dir_path = std::string()); | ||
| void set_ca_cert_store(X509_STORE *ca_cert_store); | ||
| virtual void set_ca_cert_store(X509_STORE *ca_cert_store); | ||
| X509_STORE *create_ca_cert_store(const char *ca_cert, std::size_t size) const; | ||
| #endif | ||
|
|
||
|
|
@@ -8984,7 +8984,9 @@ inline bool ClientImpl::create_redirect_client( | |
| } | ||
|
|
||
| // Handle CA certificate store and paths if available | ||
| if (ca_cert_store_) { redirect_client.set_ca_cert_store(ca_cert_store_); } | ||
| if (ca_cert_store_ && X509_STORE_up_ref(ca_cert_store_)) { | ||
| redirect_client.set_ca_cert_store(ca_cert_store_); | ||
| } | ||
| if (!ca_cert_file_path_.empty()) { | ||
| redirect_client.set_ca_cert_path(ca_cert_file_path_, ca_cert_dir_path_); | ||
| } | ||
|
|
@@ -10871,6 +10873,7 @@ inline void SSLClient::set_ca_cert_store(X509_STORE *ca_cert_store) { | |
| if (SSL_CTX_get_cert_store(ctx_) != ca_cert_store) { | ||
| // Free memory allocated for old cert and use new store `ca_cert_store` | ||
| SSL_CTX_set_cert_store(ctx_, ca_cert_store); | ||
| ca_cert_store_ = ca_cert_store; | ||
| } | ||
| } else { | ||
| X509_STORE_free(ca_cert_store); | ||
|
|
@@ -11857,7 +11860,7 @@ inline void Client::set_ca_cert_path(const std::string &ca_cert_file_path, | |
|
|
||
| inline void Client::set_ca_cert_store(X509_STORE *ca_cert_store) { | ||
| if (is_ssl_) { | ||
| static_cast<SSLClient &>(*cli_).set_ca_cert_store(ca_cert_store); | ||
| dynamic_cast<SSLClient &>(*cli_).set_ca_cert_store(ca_cert_store); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please revert it to |
||
| } else { | ||
| cli_->set_ca_cert_store(ca_cert_store); | ||
| } | ||
|
|
@@ -11869,13 +11872,13 @@ inline void Client::load_ca_cert_store(const char *ca_cert, std::size_t size) { | |
|
|
||
| inline long Client::get_openssl_verify_result() const { | ||
| if (is_ssl_) { | ||
| return static_cast<SSLClient &>(*cli_).get_openssl_verify_result(); | ||
| return dynamic_cast<SSLClient &>(*cli_).get_openssl_verify_result(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please revert it to |
||
| } | ||
| return -1; // NOTE: -1 doesn't match any of X509_V_ERR_??? | ||
| } | ||
|
|
||
| inline SSL_CTX *Client::ssl_context() const { | ||
| if (is_ssl_) { return static_cast<SSLClient &>(*cli_).ssl_context(); } | ||
| if (is_ssl_) { return dynamic_cast<SSLClient &>(*cli_).ssl_context(); } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please revert it to |
||
| return nullptr; | ||
| } | ||
| #endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove
virtual. It's not necessary.