Skip to content

Commit

Permalink
Merge pull request #1128 from gentooise/fix-ssl-options
Browse files Browse the repository at this point in the history
Resolve CURLOPT_SSL_OPTIONS issues
  • Loading branch information
COM8 authored Nov 9, 2024
2 parents ffef58e + c77c8cf commit d3e2786
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions cpr/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,6 @@ void Session::prepareCommonShared() {
}
#endif

#if LIBCURL_VERSION_NUM >= 0x071900 // 7.25.0

#if LIBCURL_VERSION_NUM >= 0x074700 // 7.71.0
// Fix loading certs from Windows cert store when using OpenSSL:
curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);
#endif

// Ensure SSL no revoke is still set
#if SUPPORT_SSL_NO_REVOKE
if (sslNoRevoke_) {
curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
}
#endif
#endif

curl_->error[0] = '\0';

// Clear the response
Expand Down Expand Up @@ -523,12 +508,21 @@ void Session::SetSslOptions(const SslOptions& options) {
curl_easy_setopt(curl_->handle, CURLOPT_SSLVERSION,
// Ignore here since this has been defined by libcurl.
maxTlsVersion);

// NOLINTNEXTLINE (google-runtime-int)
long curlSslOptions = 0;
#if SUPPORT_SSL_NO_REVOKE
sslNoRevoke_ = options.ssl_no_revoke;
if (options.ssl_no_revoke) {
curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
curlSslOptions |= CURLSSLOPT_NO_REVOKE;
}
#endif
#if LIBCURL_VERSION_NUM >= 0x074700 // 7.71.0
// Fix loading certs from Windows cert store when using OpenSSL:
curlSslOptions |= CURLSSLOPT_NATIVE_CA;
#endif
curl_easy_setopt(curl_->handle, CURLOPT_SSL_OPTIONS, curlSslOptions);

if (!options.ca_info.empty()) {
curl_easy_setopt(curl_->handle, CURLOPT_CAINFO, options.ca_info.c_str());
}
Expand Down

0 comments on commit d3e2786

Please sign in to comment.