in cli/cli.cpp [44:101]
ResponseCode CLI::InitializeTLS() {
ResponseCode rc = ResponseCode::SUCCESS;
#ifdef USE_WEBSOCKETS
p_network_connection_ = std::shared_ptr<NetworkConnection>(
new network::WebSocketConnection(ConfigCommon::endpoint_, ConfigCommon::endpoint_https_port_,
ConfigCommon::root_ca_path_, ConfigCommon::aws_region_,
ConfigCommon::aws_access_key_id_,
ConfigCommon::aws_secret_access_key_,
ConfigCommon::aws_session_token_,
ConfigCommon::tls_handshake_timeout_,
ConfigCommon::tls_read_timeout_,
ConfigCommon::tls_write_timeout_, true));
if (nullptr == p_network_connection_) {
AWS_LOG_ERROR(CLI_LOG_TAG,
"Failed to initialize Network Connection. %s",
ResponseHelper::ToString(rc).c_str());
rc = ResponseCode::FAILURE;
}
#elif defined USE_MBEDTLS
p_network_connection_ = std::make_shared<network::MbedTLSConnection>(ConfigCommon::endpoint_,
ConfigCommon::endpoint_mqtt_port_,
ConfigCommon::root_ca_path_,
ConfigCommon::client_cert_path_,
ConfigCommon::client_key_path_,
ConfigCommon::tls_handshake_timeout_,
ConfigCommon::tls_read_timeout_,
ConfigCommon::tls_write_timeout_, true);
if (nullptr == p_network_connection_) {
AWS_LOG_ERROR(CLI_LOG_TAG,
"Failed to initialize Network Connection. %s",
ResponseHelper::ToString(rc).c_str());
rc = ResponseCode::FAILURE;
}
#else
std::shared_ptr<network::OpenSSLConnection> p_network_connection =
std::make_shared<network::OpenSSLConnection>(ConfigCommon::endpoint_,
ConfigCommon::endpoint_mqtt_port_,
ConfigCommon::root_ca_path_,
ConfigCommon::client_cert_path_,
ConfigCommon::client_key_path_,
ConfigCommon::tls_handshake_timeout_,
ConfigCommon::tls_read_timeout_,
ConfigCommon::tls_write_timeout_, true);
rc = p_network_connection->Initialize();
if (ResponseCode::SUCCESS != rc) {
AWS_LOG_ERROR(CLI_LOG_TAG,
"Failed to initialize Network Connection. %s",
ResponseHelper::ToString(rc).c_str());
rc = ResponseCode::FAILURE;
} else {
p_network_connection_ = std::dynamic_pointer_cast<NetworkConnection>(p_network_connection);
}
#endif
return rc;
}