@@ -272,15 +272,14 @@ int main(int argc, char *argv[])
272
272
}
273
273
else if (useWebSocket)
274
274
{
275
- Aws::Iot::WebsocketConfig config (signingRegion, &bootstrap) ;
275
+ std::shared_ptr< Aws::Crt::Auth::ICredentialsProvider> provider = nullptr ;
276
276
277
277
Aws::Crt::Http::HttpClientConnectionProxyOptions proxyOptions;
278
278
if (!proxyHost.empty ())
279
279
{
280
280
proxyOptions.HostName = proxyHost;
281
281
proxyOptions.Port = proxyPort;
282
282
proxyOptions.AuthType = Aws::Crt::Http::AwsHttpProxyAuthenticationType::None;
283
- config.ProxyOptions = proxyOptions;
284
283
}
285
284
286
285
if (useX509)
@@ -333,12 +332,26 @@ int main(int argc, char *argv[])
333
332
x509Config.ProxyOptions = proxyOptions;
334
333
}
335
334
336
- config.CredentialsProvider = Aws::Crt::Auth::CredentialsProvider::CreateCredentialsProviderX509 (x509Config);
337
- if (!config.CredentialsProvider )
338
- {
339
- fprintf (stderr, " Failure to create X509 credentials provider!\n " );
340
- return -1 ;
341
- }
335
+ provider = Aws::Crt::Auth::CredentialsProvider::CreateCredentialsProviderX509 (x509Config);
336
+ }
337
+ else
338
+ {
339
+ Aws::Crt::Auth::CredentialsProviderChainDefaultConfig defaultConfig;
340
+ defaultConfig.Bootstrap = &bootstrap;
341
+
342
+ provider = Aws::Crt::Auth::CredentialsProvider::CreateCredentialsProviderChainDefault (defaultConfig);
343
+ }
344
+
345
+ if (!provider)
346
+ {
347
+ fprintf (stderr, " Failure to create credentials provider!\n " );
348
+ return -1 ;
349
+ }
350
+
351
+ Aws::Iot::WebsocketConfig config (signingRegion, provider);
352
+ if (!proxyHost.empty ())
353
+ {
354
+ config.ProxyOptions = proxyOptions;
342
355
}
343
356
344
357
builder = Aws::Iot::MqttClientConnectionConfigBuilder (config);
0 commit comments