Skip to content

Commit 7192d98

Browse files
committed
Fix tlsTrustCertsFilePath config is not applied for OAuth2
### Motivation #313 has reverted the fix of #190, which applies the `tlsTrustCertsFilePath` config for OAuth2 authentication. The macOS pre-built libraries are affected most because the bundled CA path is empty. ### Modification Apply the `tlsTrustCertsFilePath` for OAuth2. ### TODO Add the workflow to verify `tlsTrustCertsFilePath` is applied for OAuth2.
1 parent 0bbc155 commit 7192d98

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/auth/AuthOauth2.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,13 @@ Oauth2TokenResultPtr ClientCredentialFlow::authenticate() {
342342

343343
CurlWrapper::Options options;
344344
options.postFields = std::move(postData);
345-
auto result =
346-
curl.get(tokenEndPoint_, "Content-Type: application/x-www-form-urlencoded", options, nullptr);
345+
std::unique_ptr<CurlWrapper::TlsContext> tlsContext;
346+
if (!tlsTrustCertsFilePath_.empty()) {
347+
tlsContext.reset(new CurlWrapper::TlsContext);
348+
tlsContext->trustCertsFilePath = tlsTrustCertsFilePath_;
349+
}
350+
auto result = curl.get(tokenEndPoint_, "Content-Type: application/x-www-form-urlencoded", options,
351+
tlsContext.get());
347352
if (!result.error.empty()) {
348353
LOG_ERROR("Failed to get the well-known configuration " << issuerUrl_ << ": " << result.error);
349354
return resultPtr;

0 commit comments

Comments
 (0)