in src/aws-cpp-sdk-core/source/http/crt/CRTHttpClient.cpp [565:626]
void CRTHttpClient::CheckAndInitializeProxySettings(const Aws::Client::ClientConfiguration& clientConfig)
{
if (!clientConfig.proxyHost.empty())
{
Crt::Http::HttpClientConnectionProxyOptions proxyOptions;
if (!clientConfig.proxyUserName.empty())
{
proxyOptions.AuthType = Crt::Http::AwsHttpProxyAuthenticationType::Basic;
proxyOptions.BasicAuthUsername = clientConfig.proxyUserName.c_str();
proxyOptions.BasicAuthPassword = clientConfig.proxyPassword.c_str();
}
proxyOptions.HostName = m_configuration.proxyHost.c_str();
if (clientConfig.proxyPort != 0)
{
proxyOptions.Port = static_cast<uint16_t>(clientConfig.proxyPort);
}
else
{
proxyOptions.Port = clientConfig.proxyScheme == Scheme::HTTPS ? 443 : 80;
}
if (clientConfig.proxyScheme == Scheme::HTTPS)
{
Crt::Io::TlsContextOptions contextOptions = Crt::Io::TlsContextOptions::InitDefaultClient();
if (clientConfig.proxySSLKeyPassword.empty() && !clientConfig.proxySSLCertPath.empty())
{
const char* certPath = clientConfig.proxySSLCertPath.empty() ? nullptr : clientConfig.proxySSLCertPath.c_str();
const char* certFile = clientConfig.proxySSLKeyPath.empty() ? nullptr : clientConfig.proxySSLKeyPath.c_str();
contextOptions = Crt::Io::TlsContextOptions::InitClientWithMtls(certPath, certFile);
}
else if (!clientConfig.proxySSLKeyPassword.empty())
{
const char* pkcs12CertFile = clientConfig.proxySSLKeyPath.empty() ? nullptr : clientConfig.proxySSLKeyPath.c_str();
const char* pkcs12Pwd = clientConfig.proxySSLKeyPassword.c_str();
contextOptions = Crt::Io::TlsContextOptions::InitClientWithMtlsPkcs12(pkcs12CertFile, pkcs12Pwd);
}
if (!m_configuration.proxyCaFile.empty() || !m_configuration.proxyCaPath.empty())
{
const char* caPath = clientConfig.proxyCaPath.empty() ? nullptr : clientConfig.proxyCaPath.c_str();
const char* caFile = clientConfig.proxyCaFile.empty() ? nullptr : clientConfig.proxyCaFile.c_str();
contextOptions.OverrideDefaultTrustStore(caPath, caFile);
}
else if (!m_configuration.caFile.empty() || !m_configuration.caPath.empty())
{
const char* caPath = clientConfig.caPath.empty() ? nullptr : clientConfig.caPath.c_str();
const char* caFile = clientConfig.caFile.empty() ? nullptr : clientConfig.caFile.c_str();
contextOptions.OverrideDefaultTrustStore(caPath, caFile);
}
contextOptions.SetVerifyPeer(clientConfig.verifySSL);
Crt::Io::TlsContext context = Crt::Io::TlsContext(contextOptions, Crt::Io::TlsMode::CLIENT);
proxyOptions.TlsOptions = context.NewConnectionOptions();
}
m_proxyOptions = std::move(proxyOptions);
}
}