Skip to content
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

Resolve CURLOPT_SSL_OPTIONS issues #1128

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
gentooise marked this conversation as resolved.
Show resolved Hide resolved
#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
Loading