1+ /* *
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0.
4+ */
5+ #include < aws/core/Globals.h>
16#include < aws/core/auth/CrtCredentialsProvider.h>
27#include < aws/core/auth/ProfileCredentialsProvider.h>
38#include < aws/core/client/UserAgent.h>
49#include < aws/core/platform/Environment.h>
510#include < aws/core/platform/FileSystem.h>
611#include < aws/crt/auth/Credentials.h>
12+ #include < aws/crt/http/HttpConnection.h>
713
814#include < chrono>
915
@@ -17,6 +23,23 @@ const char PROFILE_AWS_CREDENTIALS_FILE[] = "AWS_SHARED_CREDENTIALS_FILE";
1723const char PROFILE_DEFAULT_CREDENTIALS_FILE [] = " credentials" ;
1824const char PROFILE_PROFILE_DIRECTORY [] = " .aws" ;
1925const long DEFAULT_REFRESH_RATE_MS = 300000 ;
26+
27+ std::shared_ptr<Aws::Crt::Auth::ICredentialsProvider> GetProfileCrtProvider (const char * profile) {
28+ CredentialsProviderProfileConfig config{};
29+ config.ProfileNameOverride = Aws::Crt::ByteCursorFromCString (profile);
30+ config.Bootstrap = Aws::GetDefaultClientBootstrap ();
31+
32+ Aws::Crt::Http::ProxyEnvVarOptions options{};
33+ options.proxyEnvVarType = Aws::Crt::Http::ProxyEnvVarType::Enabled;
34+ options.connectionType = Aws::Crt::Http::AwsHttpProxyConnectionType::Legacy;
35+ const auto tlsOptions = Aws::GetDefaultTlsConnectionOptions ();
36+ if (tlsOptions) {
37+ options.TlsOptions = *tlsOptions;
38+ }
39+ config.ProxyEnvVarOptions = options;
40+
41+ return CredentialsProvider::CreateCredentialsProviderProfile (config);
42+ }
2043} // namespace
2144
2245class ProfileCredentialsProvider ::ProfileCredentialsProviderImp : public CrtCredentialsProvider {
@@ -32,9 +55,7 @@ class ProfileCredentialsProvider::ProfileCredentialsProviderImp : public CrtCred
3255 ProfileCredentialsProviderImp (const char * profile)
3356 : CrtCredentialsProvider(
3457 [profile]() -> std::shared_ptr<ICredentialsProvider> {
35- CredentialsProviderProfileConfig config;
36- config.ProfileNameOverride = Aws::Crt::ByteCursorFromCString (profile);
37- return CredentialsProvider::CreateCredentialsProviderProfile (config);
58+ return GetProfileCrtProvider (profile);
3859 },
3960 std::chrono::milliseconds (DEFAULT_REFRESH_RATE_MS ), UserAgentFeature::CREDENTIALS_PROFILE ,
4061 " ProfileCredentialsProvider" ) {}
0 commit comments