diff --git a/aws-common-runtime/aws-crt-cpp b/aws-common-runtime/aws-crt-cpp index 7d3c0b40d..e84c3402e 160000 --- a/aws-common-runtime/aws-crt-cpp +++ b/aws-common-runtime/aws-crt-cpp @@ -1 +1 @@ -Subproject commit 7d3c0b40d83a9d7a22821b302947b0fba3f4be01 +Subproject commit e84c3402ee0a1d00d5d66a0a8e803f33a64fccb4 diff --git a/discovery/source/DiscoveryClient.cpp b/discovery/source/DiscoveryClient.cpp index 10957722e..bffe79cc5 100644 --- a/discovery/source/DiscoveryClient.cpp +++ b/discovery/source/DiscoveryClient.cpp @@ -180,7 +180,13 @@ namespace Aws } }; - if (!connection->NewClientStream(requestOptions)) + auto stream = connection->NewClientStream(requestOptions); + if (!stream) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); + } + + if (!stream->Activate()) { onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); } diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index 53fbdd79f..98f2ecfaa 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -33,7 +33,7 @@ static void s_printHelp() fprintf( stdout, "basic-discovery --region --cert " - " --key --ca_file " + " --key --ca_file " " --thing_name --topic " " --mode --message " " --proxy-host --proxy-port \n\n"); @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) /*********************** Parse Arguments ***************************/ if (!(s_cmdOptionExists(argv, argv + argc, "--cert") && s_cmdOptionExists(argv, argv + argc, "--key") && - s_cmdOptionExists(argv, argv + argc, "--thing_name") && s_cmdOptionExists(argv, argv + argc, "--ca_file"))) + s_cmdOptionExists(argv, argv + argc, "--thing_name"))) { s_printHelp(); return 0; @@ -95,7 +95,11 @@ int main(int argc, char *argv[]) certificatePath = s_getCmdOption(argv, argv + argc, "--cert"); keyPath = s_getCmdOption(argv, argv + argc, "--key"); thingName = s_getCmdOption(argv, argv + argc, "--thing_name"); - caFile = s_getCmdOption(argv, argv + argc, "--ca_file"); + + if (s_cmdOptionExists(argv, argv + argc, "--ca_file")) + { + caFile = s_getCmdOption(argv, argv + argc, "--ca_file"); + } if (s_cmdOptionExists(argv, argv + argc, "--region")) { @@ -142,7 +146,17 @@ int main(int argc, char *argv[]) Io::TlsContextOptions tlsCtxOptions = Io::TlsContextOptions::InitClientWithMtls(certificatePath.c_str(), keyPath.c_str()); - tlsCtxOptions.OverrideDefaultTrustStore(nullptr, caFile.c_str()); + if (!tlsCtxOptions) + { + fprintf(stderr, "TLS Context Options creation failed with error %s\n", ErrorDebugString(Aws::Crt::LastError())); + exit(-1); + } + + if (!caFile.empty()) + { + tlsCtxOptions.OverrideDefaultTrustStore(nullptr, caFile.c_str()); + } + Io::TlsContext tlsCtx(tlsCtxOptions, Io::TlsMode::CLIENT); if (!tlsCtx)