in aws_common/src/sdk_utils/auth/service_credentials_provider.cpp [196:248]
bool GetServiceAuthConfig(ServiceAuthConfig & config,
const std::shared_ptr<Aws::Client::ParameterReaderInterface>& parameters)
{
bool failed = false;
Aws::String cafile, certfile, keyfile, host, role, name;
int connect_timeout_ms = DEFAULT_AUTH_CONNECT_TIMEOUT_MS;
int total_timeout_ms = DEFAULT_AUTH_TOTAL_TIMEOUT_MS;
std::map<std::string, std::string> data;
if (parameters->ReadParam(Aws::Client::ParameterPath("iot"), data) != AWS_ERR_OK) {
failed = true;
} else {
if (!GetConfigValue(data, CFG_CAFILE, cafile)) { failed = true; }
if (!GetConfigValue(data, CFG_CERTFILE, certfile)) { failed = true; }
if (!GetConfigValue(data, CFG_KEYFILE, keyfile)) { failed = true; }
if (!GetConfigValue(data, CFG_ENDPOINT, host)) { failed = true; }
if (!GetConfigValue(data, CFG_ROLE, role)) { failed = true; }
if (!GetConfigValue(data, CFG_THING_NAME, name)) { failed = true; }
if (!GetConfigValue(data, CFG_CONNECT_TIMEOUT_MS, connect_timeout_ms, true)) {
AWS_LOG_INFO(AWS_LOG_TAG, "Could not find config value %s, using default %d",
CFG_CONNECT_TIMEOUT_MS, DEFAULT_AUTH_CONNECT_TIMEOUT_MS);
}
if (!GetConfigValue(data, CFG_TOTAL_TIMEOUT_MS, total_timeout_ms, true)) {
AWS_LOG_INFO(AWS_LOG_TAG, "Could not find config value %s, using default %d",
CFG_TOTAL_TIMEOUT_MS, DEFAULT_AUTH_TOTAL_TIMEOUT_MS);
}
}
if (!failed) {
config.iot.cafile = cafile;
config.iot.certfile = certfile;
config.iot.keyfile = keyfile;
config.iot.host = host;
config.iot.role = role;
config.iot.name = name;
config.iot.connect_timeout_ms = connect_timeout_ms;
config.iot.total_timeout_ms = total_timeout_ms;
AWS_LOG_INFO(AWS_LOG_TAG,
"IoT provider config: ca=%s,cert=%s,key=%s,ep=%s,role=%s,thing_name=%s,"
"connect_timeout=%d,total_timeout=%d",
config.iot.cafile.c_str(), config.iot.certfile.c_str(), config.iot.keyfile.c_str(),
config.iot.host.c_str(), config.iot.role.c_str(), config.iot.name.c_str(),
config.iot.connect_timeout_ms, config.iot.total_timeout_ms);
return true;
}
AWS_LOG_INFO(AWS_LOG_TAG,
"Missing or incomplete 'iot' parameters, skipping IoT credential provider");
return false;
}