diff --git a/cpr/session.cpp b/cpr/session.cpp index 4c16c47ee..bc3d405da 100644 --- a/cpr/session.cpp +++ b/cpr/session.cpp @@ -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 @@ -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()); }