Skip to content

Commit ad41e2e

Browse files
committed
return error if libcurl version is insufficient to use client cert
1 parent b3156ec commit ad41e2e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

google/cloud/internal/curl_impl.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ Status CurlImpl::MakeRequest(HttpMethod method, RestContext& context,
333333
if (!status.ok()) return OnTransferError(context, std::move(status));
334334
}
335335

336-
#if CURL_AT_LEAST_VERSION(7, 71, 0)
337336
if (client_ssl_cert_.has_value()) {
337+
#if CURL_AT_LEAST_VERSION(7, 71, 0)
338338
status = handle_.SetOption(CURLOPT_SSL_VERIFYPEER, 1L);
339339
if (!status.ok()) return OnTransferError(context, std::move(status));
340340
status = handle_.SetOption(CURLOPT_SSL_VERIFYHOST, 2L);
@@ -361,8 +361,15 @@ Status CurlImpl::MakeRequest(HttpMethod method, RestContext& context,
361361
ssl_key_blob.flags = CURL_BLOB_COPY;
362362
status = handle_.SetOption(CURLOPT_SSLKEY_BLOB, &ssl_key_blob);
363363
if (!status.ok()) return OnTransferError(context, std::move(status));
364-
}
364+
#else
365+
return OnTransferError(
366+
context,
367+
internal::InvalidArgumentError(
368+
"libcurl 7.71.0 or higher required to use ClientSslCertificate",
369+
GCP_ERROR_INFO().WithMetadata("current_libcurl_version",
370+
LIBCURL_VERSION)));
365371
#endif
372+
}
366373

367374
if (method == HttpMethod::kGet) {
368375
status = handle_.SetOption(CURLOPT_NOPROGRESS, 1L);

0 commit comments

Comments
 (0)