Skip to content

Commit df6be9b

Browse files
committed
enable HTTPS_PROXY var for crt credentials providers
1 parent 6043165 commit df6be9b

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/aws-cpp-sdk-core/source/auth/ProfileCredentialsProvider.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
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";
1723
const char PROFILE_DEFAULT_CREDENTIALS_FILE[] = "credentials";
1824
const char PROFILE_PROFILE_DIRECTORY[] = ".aws";
1925
const 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

2245
class 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") {}

src/aws-cpp-sdk-core/source/auth/STSCredentialsProvider.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ std::shared_ptr<Aws::Crt::Auth::ICredentialsProvider> GetSTSCrtProvider(
3535
}()
3636
.c_str();
3737

38+
Aws::Crt::Http::ProxyEnvVarOptions options{};
39+
options.proxyEnvVarType = Aws::Crt::Http::ProxyEnvVarType::Enabled;
40+
options.connectionType = Aws::Crt::Http::AwsHttpProxyConnectionType::Legacy;
41+
if (tlsOptions) {
42+
options.TlsOptions = *tlsOptions;
43+
}
44+
stsConfig.ProxyEnvVarOptions = options;
45+
3846
return Aws::Crt::Auth::CredentialsProvider::CreateCredentialsProviderSTSWebIdentity(stsConfig);
3947
}
4048
} // namespace

0 commit comments

Comments
 (0)