From 7ed2a38a8f62dd86ea89da4f8b16c27576e1a8f5 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Fri, 23 May 2025 09:33:53 +0000 Subject: [PATCH 01/22] Remove curl commands for downloading cmake --- .github/workflows/ci.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba0fd90273..ef9174c0b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,9 @@ jobs: submodules: recursive - name: Configure CMake build run: | - sudo apt-get install -y libmosquitto-dev - curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz - tar -xf cmake.tar.gz + sudo apt-get install -y libmosquitto-dev cmake mkdir build && cd build - ../cmake-3.2.0-Linux-x86_64/bin/cmake .. \ + cmake .. \ -G "Unix Makefiles" \ -DBUILD_DEMOS=1 \ -DCMAKE_BUILD_TYPE=Release \ @@ -63,11 +61,9 @@ jobs: done - name: Configure CMake build run: | - sudo apt-get install -y libmosquitto-dev - curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz - tar -xf cmake.tar.gz + sudo apt-get install -y libmosquitto-dev cmake mkdir build && cd build - ../cmake-3.2.0-Linux-x86_64/bin/cmake .. \ + cmake .. \ -G "Unix Makefiles" \ -DBUILD_DEMOS=1 \ -DCMAKE_BUILD_TYPE=Release \ @@ -99,10 +95,9 @@ jobs: submodules: recursive - name: Configure CMake for installation of shared libraries at custom location run: | - curl https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz -o cmake.tar.gz - tar -xf cmake.tar.gz + sudo apt-get install -y cmake mkdir build && cd build - ../cmake-3.2.0-Linux-x86_64/bin/cmake .. \ + cmake .. \ -DBUILD_DEMOS=0 \ -DCSDK_HEADER_INSTALL_PATH="$PWD/../shared-libs-headers-install-dir" -DCSDK_LIB_INSTALL_PATH="$PWD/../shared-libs-install-dir" - name: Install shared libraries and verify custom install location From c904496ae8d620ae3742364675dedd7775d8b8af Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Fri, 23 May 2025 09:45:43 +0000 Subject: [PATCH 02/22] Update ubuntu version to latest from 20.04 --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/localhost_demo_runner.yml | 2 +- .github/workflows/release-automation.yml | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef9174c0b1..f1ed66edcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: build-check-demos: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Clone This Repo uses: actions/checkout@v2 @@ -44,7 +44,7 @@ jobs: make -C build/ help | grep demo | tr -d '. ' | xargs make -C build/ make -C demos/jobs/jobs_demo_mosquitto build-check-demos-cpp: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Clone This Repo uses: actions/checkout@v2 @@ -87,7 +87,7 @@ jobs: run: | make -C build/ help | grep demo | tr -d '. ' | xargs make -C build/ build-check-install: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Clone This Repo uses: actions/checkout@v2 @@ -160,7 +160,7 @@ jobs: # Each line of install_manifest.txt contains the location of an installed library or header done Date: Fri, 23 May 2025 10:04:23 +0000 Subject: [PATCH 03/22] Update python version in link verifier --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1ed66edcf..0b440949d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -252,7 +252,7 @@ jobs: - name: Setup Python for link verifier action uses: actions/setup-python@v2 with: - python-version: '3.7.10' + python-version: '3.8' - name: Check Links env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 39e91e0b5e43ec9300e541e89e833b5f3eeabb19 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Fri, 23 May 2025 10:13:13 +0000 Subject: [PATCH 04/22] Fix demos for updating ubuntu version --- .../fleet_provisioning_with_csr/pkcs11_operations.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/demos/fleet_provisioning/fleet_provisioning_with_csr/pkcs11_operations.c b/demos/fleet_provisioning/fleet_provisioning_with_csr/pkcs11_operations.c index bd4b48a899..d2987dc0ab 100644 --- a/demos/fleet_provisioning/fleet_provisioning_with_csr/pkcs11_operations.c +++ b/demos/fleet_provisioning/fleet_provisioning_with_csr/pkcs11_operations.c @@ -936,10 +936,12 @@ static int32_t privateKeySigningCallback( mbedtls_pk_context * pContext, { ret = CKR_ARGUMENTS_BAD; } - - mech.mechanism = CKM_ECDSA; - memcpy( toBeSigned, pHash, hashLen ); - toBeSignedLen = hashLen; + else + { + mech.mechanism = CKM_ECDSA; + memcpy( toBeSigned, pHash, hashLen ); + toBeSignedLen = hashLen; + } if( ret == CKR_OK ) { From e2a9de759d153ef5f85a81d42566aca77585496b Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Fri, 23 May 2025 10:16:19 +0000 Subject: [PATCH 05/22] Update cmake instructions to use the ubuntu installed cmake --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b440949d4..6872b93ef9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: - name: Configure CMake for installation of static libraries at custom location run: | cd build - ../cmake-3.2.0-Linux-x86_64/bin/cmake .. \ + cmake .. \ -DBUILD_SHARED_LIBRARIES=OFF \ -DBUILD_DEMOS=0 \ -DCSDK_HEADER_INSTALL_PATH="$PWD/../static-libs-headers-install-dir" -DCSDK_LIB_INSTALL_PATH="$PWD/../static-libs-install-dir" @@ -136,7 +136,7 @@ jobs: - name: Configure CMake build for system install location and selective installation run: | cd build - ../cmake-3.2.0-Linux-x86_64/bin/cmake .. \ + cmake .. \ -DBUILD_DEMOS=0 -DBUILD_TESTS=0 -DINSTALL_TO_SYSTEM=1 \ -DINSTALL_LIBS="SHADOW;DEFENDER" -DINSTALL_PLATFORM_ABSTRACTIONS=0 - name: Install selected libraries and verify default system installation path is used From 9c3e01947dd4248f11a2b153f1a30a15fdf870c8 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Sat, 24 May 2025 17:49:54 +0000 Subject: [PATCH 06/22] Update cmake to latest in localhost_demo_runner --- .github/workflows/localhost_demo_runner.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/localhost_demo_runner.yml b/.github/workflows/localhost_demo_runner.yml index 03a1425cbf..762510a6e8 100644 --- a/.github/workflows/localhost_demo_runner.yml +++ b/.github/workflows/localhost_demo_runner.yml @@ -28,9 +28,7 @@ jobs: - name: Install CMake id: install-cmake - uses: lukka/get-cmake@v3.26.0 - with: - cmakeVersion: 3.2.0 + run: sudo apt-get install -y cmake - name: Generate SSL credentials id: generate-credentials From e231f4a527fcb0fc12db60fcf7312a5b4e5be422 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Sat, 24 May 2025 19:26:10 +0000 Subject: [PATCH 07/22] Fix Error 403 in links --- demos/pkcs11/pkcs11_demo_objects/pkcs11_demo_objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/pkcs11/pkcs11_demo_objects/pkcs11_demo_objects.c b/demos/pkcs11/pkcs11_demo_objects/pkcs11_demo_objects.c index 27d08ec9e1..9bc973bcbe 100644 --- a/demos/pkcs11/pkcs11_demo_objects/pkcs11_demo_objects.c +++ b/demos/pkcs11/pkcs11_demo_objects/pkcs11_demo_objects.c @@ -284,7 +284,7 @@ static CK_RV objectImporting( void ) * * See this explanation for the difference between the PEM format and the * DER format: - * https://stackoverflow.com/questions/22743415/what-are-the-differences-between-pem-cer-and-der/22743616 + * https://www.ssl.com/guide/pem-der-crt-and-cer-x-509-encodings-and-conversions/ * */ if( result == CKR_OK ) From c23b5b67c8d8ed4f93484b30b8cc70075ca111be Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Sat, 24 May 2025 19:37:19 +0000 Subject: [PATCH 08/22] Fix demos in CI checks --- demos/http/http_demo_s3_download/http_demo_s3_download.c | 2 +- .../http_demo_s3_generate_presigned_url.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/http/http_demo_s3_download/http_demo_s3_download.c b/demos/http/http_demo_s3_download/http_demo_s3_download.c index 0b73c2d8cb..1abe9263df 100644 --- a/demos/http/http_demo_s3_download/http_demo_s3_download.c +++ b/demos/http/http_demo_s3_download/http_demo_s3_download.c @@ -349,7 +349,7 @@ static SigV4CryptoInterface_t cryptoInterface = * @brief SigV4 parameters provided to SigV4 library by the application for generating * the Authorization header. */ -static SigV4Parameters_t sigv4Params = +SigV4Parameters_t sigv4Params = { .pCredentials = &sigvCreds, .pDateIso8601 = pDateISO8601, diff --git a/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c b/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c index 2c0e0c437f..9cfd9eae28 100644 --- a/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c +++ b/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c @@ -246,7 +246,7 @@ static SigV4CryptoInterface_t cryptoInterface = * @brief SigV4 parameters provided to SigV4 library by the application for generating * the Authorization header. */ -static SigV4Parameters_t sigv4Params = +SigV4Parameters_t sigv4Params = { .pCredentials = &sigvCreds, .pDateIso8601 = pDateISO8601, From 3faa78ff6b39539bcf3f454c6bbc4a98990c64bd Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Sat, 24 May 2025 20:06:42 +0000 Subject: [PATCH 09/22] Fix demos as static in CI checks --- demos/http/http_demo_s3_download/http_demo_s3_download.c | 6 +++--- .../http_demo_s3_generate_presigned_url.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/demos/http/http_demo_s3_download/http_demo_s3_download.c b/demos/http/http_demo_s3_download/http_demo_s3_download.c index 1abe9263df..b1eaf0d4c8 100644 --- a/demos/http/http_demo_s3_download/http_demo_s3_download.c +++ b/demos/http/http_demo_s3_download/http_demo_s3_download.c @@ -345,11 +345,13 @@ static SigV4CryptoInterface_t cryptoInterface = .hashDigestLen = SHA256_HASH_DIGEST_LENGTH, }; +static SigV4HttpParameters_t sigv4HttpParams; + /** * @brief SigV4 parameters provided to SigV4 library by the application for generating * the Authorization header. */ -SigV4Parameters_t sigv4Params = +static SigV4Parameters_t sigv4Params = { .pCredentials = &sigvCreds, .pDateIso8601 = pDateISO8601, @@ -453,7 +455,6 @@ static bool downloadS3ObjectFile( const TransportInterface_t * pTransportInterfa size_t curByte = 0; SigV4Status_t sigv4Status = SigV4Success; - SigV4HttpParameters_t sigv4HttpParams; char * pHeaders = NULL; size_t headersLen = 0; @@ -720,7 +721,6 @@ static bool getS3ObjectFileSize( size_t * pFileSize, size_t contentRangeValStrLength = 0; SigV4Status_t sigv4Status = SigV4Success; - SigV4HttpParameters_t sigv4HttpParams; char * pHeaders = NULL; size_t headersLen = 0; diff --git a/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c b/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c index 9cfd9eae28..c81108e989 100644 --- a/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c +++ b/demos/http/http_demo_s3_generate_presigned_url/http_demo_s3_generate_presigned_url.c @@ -242,11 +242,13 @@ static SigV4CryptoInterface_t cryptoInterface = .hashDigestLen = SHA256_HASH_DIGEST_LENGTH, }; +static SigV4HttpParameters_t sigv4HttpParams; + /** * @brief SigV4 parameters provided to SigV4 library by the application for generating * the Authorization header. */ -SigV4Parameters_t sigv4Params = +static SigV4Parameters_t sigv4Params = { .pCredentials = &sigvCreds, .pDateIso8601 = pDateISO8601, @@ -273,7 +275,6 @@ static bool printS3ObjectFilePresignedURL( const char * pHost, uint8_t userBuffer[ USER_BUFFER_LENGTH ]; SigV4Status_t sigv4Status = SigV4Success; - SigV4HttpParameters_t sigv4HttpParams; char * pHeaders = NULL; size_t headersLen = 0; From a0742e7084630d24bb4ec7d39ea5ff56dbcfdbeb Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 04:10:12 +0000 Subject: [PATCH 10/22] Fix http_demo_mutual_auth --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 8204923857..5562052c2f 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -401,6 +401,10 @@ int main( int argc, { /* Log message indicating an iteration completed successfully. */ LogInfo( ( "Demo completed successfully." ) ); + + /* Ensure logs are flushed before exiting. */ + fflush( stdout ); + fflush( stderr ); } /************************** Disconnect. *****************************/ From e0b3fae8122cab2fab30d35ab99001078e76b57a Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 04:18:33 +0000 Subject: [PATCH 11/22] Fix http_demo_mutual_auth --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 5562052c2f..b4836469a9 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -399,8 +399,9 @@ int main( int argc, if( returnStatus == EXIT_SUCCESS ) { + LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - LogInfo( ( "Demo completed successfully." ) ); + printf( ( "Demo completed successfully." ) ); /* Ensure logs are flushed before exiting. */ fflush( stdout ); From b172dcba6269059281fb134d59d93055087fb1e2 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:02:40 +0000 Subject: [PATCH 12/22] Duimmy check for retStatus --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index b4836469a9..ed3b4c9d60 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -395,6 +395,7 @@ int main( int argc, HTTP_METHOD_POST_LENGTH, POST_PATH, POST_PATH_LENGTH ); + LogInfo( ( "Final returnStatus = %d", returnStatus ) ); } if( returnStatus == EXIT_SUCCESS ) From 4747f1055da65540d2e20a6924a5b230c14b5e45 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:07:44 +0000 Subject: [PATCH 13/22] Dummy check for retStatus --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index ed3b4c9d60..aaa8c0bccb 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -402,7 +402,7 @@ int main( int argc, { LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - printf( ( "Demo completed successfully." ) ); + LogInfo( ( "Demo completed successfully." ) ); /* Ensure logs are flushed before exiting. */ fflush( stdout ); From 2d9d8306a710d5a2ac9582d3519023b247e221c2 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:12:55 +0000 Subject: [PATCH 14/22] Dummy check for retStatus --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index aaa8c0bccb..4b5243c04b 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -402,7 +402,7 @@ int main( int argc, { LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - LogInfo( ( "Demo completed successfully." ) ); + printf( "Demo completed successfully." ); /* Ensure logs are flushed before exiting. */ fflush( stdout ); From 5d830b7730e5ff35099892a8c44446d02105dd13 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:17:51 +0000 Subject: [PATCH 15/22] Dummy check for retStatus --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 4b5243c04b..9dc8fa7e15 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -402,7 +402,7 @@ int main( int argc, { LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - printf( "Demo completed successfully." ); + //printf( "Demo completed successfully." ); /* Ensure logs are flushed before exiting. */ fflush( stdout ); From 1162a884e50e8292dba26715f56d163aea1e4fc5 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:29:18 +0000 Subject: [PATCH 16/22] Dummy check for retStatus --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 9dc8fa7e15..9e024c8d96 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -395,7 +395,9 @@ int main( int argc, HTTP_METHOD_POST_LENGTH, POST_PATH, POST_PATH_LENGTH ); - LogInfo( ( "Final returnStatus = %d", returnStatus ) ); + + LogInfo( ( "ABC") ); + LogInfo( ( "Final returnStatus = %d", returnStatus ) ); } if( returnStatus == EXIT_SUCCESS ) @@ -403,10 +405,6 @@ int main( int argc, LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ //printf( "Demo completed successfully." ); - - /* Ensure logs are flushed before exiting. */ - fflush( stdout ); - fflush( stderr ); } /************************** Disconnect. *****************************/ From aedfec78f1161c62286b58ae23b126fa85bba50a Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 05:54:16 +0000 Subject: [PATCH 17/22] Check logging --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 9e024c8d96..8f0d6e7730 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -395,16 +395,16 @@ int main( int argc, HTTP_METHOD_POST_LENGTH, POST_PATH, POST_PATH_LENGTH ); - - LogInfo( ( "ABC") ); - LogInfo( ( "Final returnStatus = %d", returnStatus ) ); } + LogInfo( ( "ABC" ) ); + LogInfo( ( "Final returnStatus = %d", returnStatus ) ); + if( returnStatus == EXIT_SUCCESS ) { LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - //printf( "Demo completed successfully." ); + /*printf( "Demo completed successfully." ); */ } /************************** Disconnect. *****************************/ From 54f1c704487de264681f1eb2bca275201a54e060 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 06:02:03 +0000 Subject: [PATCH 18/22] Check logging --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 8f0d6e7730..419071e7a2 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -312,6 +312,9 @@ static int32_t sendHttpRequest( const TransportInterface_t * pTransportInterface HTTPClient_strerror( httpStatus ) ) ); } + LogInfo( ( "ABC" ) ); + fflush(stdout); + if( httpStatus != HTTPSuccess ) { returnStatus = EXIT_FAILURE; @@ -397,14 +400,10 @@ int main( int argc, POST_PATH_LENGTH ); } - LogInfo( ( "ABC" ) ); - LogInfo( ( "Final returnStatus = %d", returnStatus ) ); - if( returnStatus == EXIT_SUCCESS ) { - LogInfo( ( "Rahul" ) ); /* Log message indicating an iteration completed successfully. */ - /*printf( "Demo completed successfully." ); */ + LogInfo( ( "Demo completed successfully." ) ); } /************************** Disconnect. *****************************/ From 845e65e94121a4994c516f3cea9834253acd0560 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 06:20:50 +0000 Subject: [PATCH 19/22] Check logging --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 419071e7a2..38a0864892 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -313,7 +313,8 @@ static int32_t sendHttpRequest( const TransportInterface_t * pTransportInterface } LogInfo( ( "ABC" ) ); - fflush(stdout); + fflush( stdout ); + fflush( stderr ); if( httpStatus != HTTPSuccess ) { From 9d47772a74d66760155e5a393a8a90218fa155d5 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 06:59:10 +0000 Subject: [PATCH 20/22] Add iterations to the http mutual auth demo --- .../http_demo_mutual_auth.c | 120 ++++++++++-------- 1 file changed, 70 insertions(+), 50 deletions(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index 38a0864892..ab5700223f 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -58,6 +58,11 @@ #error "Please define a POST_PATH." #endif +/** + * @brief Delay in seconds between each iteration of the demo. + */ +#define DEMO_LOOP_DELAY_SECONDS ( 5U ) + /* Check that a path for Root CA certificate is defined. */ #ifndef ROOT_CA_CERT_PATH #error "Please define a ROOT_CA_CERT_PATH." @@ -108,6 +113,11 @@ */ #define REQUEST_BODY_LENGTH ( sizeof( REQUEST_BODY ) - 1 ) +/** + * @brief Number of HTTP paths to request. + */ +#define NUMBER_HTTP_PATHS ( 4 ) + /** * @brief A buffer used in the demo for storing HTTP request headers and * HTTP response headers and body. @@ -312,10 +322,6 @@ static int32_t sendHttpRequest( const TransportInterface_t * pTransportInterface HTTPClient_strerror( httpStatus ) ) ); } - LogInfo( ( "ABC" ) ); - fflush( stdout ); - fflush( stderr ); - if( httpStatus != HTTPSuccess ) { returnStatus = EXIT_FAILURE; @@ -356,61 +362,75 @@ int main( int argc, /* Set the pParams member of the network context with desired transport. */ networkContext.pParams = &opensslParams; - /**************************** Connect. ******************************/ - - /* Establish TLS connection on top of TCP connection using OpenSSL. */ - if( returnStatus == EXIT_SUCCESS ) + for( ; ; ) { - LogInfo( ( "Performing TLS handshake on top of the TCP connection." ) ); + int i = 0; - /* Attempt to connect to the HTTP server. If connection fails, retry after - * a timeout. Timeout value will be exponentially increased till the maximum - * attempts are reached or maximum timeout value is reached. The function - * returns EXIT_FAILURE if the TCP connection cannot be established to - * broker after configured number of attempts. */ - returnStatus = connectToServerWithBackoffRetries( connectToServer, - &networkContext ); + /**************************** Connect. ******************************/ - if( returnStatus == EXIT_FAILURE ) + /* Establish TLS connection on top of TCP connection using OpenSSL. */ + if( returnStatus == EXIT_SUCCESS ) { - /* Log error to indicate connection failure after all - * reconnect attempts are over. */ - LogError( ( "Failed to connect to HTTP server %.*s.", - ( int32_t ) AWS_IOT_ENDPOINT_LENGTH, - AWS_IOT_ENDPOINT ) ); + LogInfo( ( "Performing TLS handshake on top of the TCP connection." ) ); + + /* Attempt to connect to the HTTP server. If connection fails, retry after + * a timeout. Timeout value will be exponentially increased till the maximum + * attempts are reached or maximum timeout value is reached. The function + * returns EXIT_FAILURE if the TCP connection cannot be established to + * broker after configured number of attempts. */ + returnStatus = connectToServerWithBackoffRetries( connectToServer, + &networkContext ); + + if( returnStatus == EXIT_FAILURE ) + { + /* Log error to indicate connection failure after all + * reconnect attempts are over. */ + LogError( ( "Failed to connect to HTTP server %.*s.", + ( int32_t ) AWS_IOT_ENDPOINT_LENGTH, + AWS_IOT_ENDPOINT ) ); + } } - } - /* Define the transport interface. */ - if( returnStatus == EXIT_SUCCESS ) - { - ( void ) memset( &transportInterface, 0, sizeof( transportInterface ) ); - transportInterface.recv = Openssl_Recv; - transportInterface.send = Openssl_Send; - transportInterface.pNetworkContext = &networkContext; - } + /* Define the transport interface. */ + if( returnStatus == EXIT_SUCCESS ) + { + ( void ) memset( &transportInterface, 0, sizeof( transportInterface ) ); + transportInterface.recv = Openssl_Recv; + transportInterface.send = Openssl_Send; + transportInterface.pNetworkContext = &networkContext; + } - /*********************** Send HTTPS request. ************************/ + /*********************** Send HTTPS requests. ************************/ - if( returnStatus == EXIT_SUCCESS ) - { - returnStatus = sendHttpRequest( &transportInterface, - HTTP_METHOD_POST, - HTTP_METHOD_POST_LENGTH, - POST_PATH, - POST_PATH_LENGTH ); - } + for( i = 0; i < NUMBER_HTTP_PATHS; i++ ) + { + if( returnStatus == EXIT_SUCCESS ) + { + returnStatus = sendHttpRequest( &transportInterface, + HTTP_METHOD_POST, + HTTP_METHOD_POST_LENGTH, + POST_PATH, + POST_PATH_LENGTH ); + } + else + { + break; + } + } - if( returnStatus == EXIT_SUCCESS ) - { - /* Log message indicating an iteration completed successfully. */ - LogInfo( ( "Demo completed successfully." ) ); - } + if( returnStatus == EXIT_SUCCESS ) + { + /* Log message indicating an iteration completed successfully. */ + LogInfo( ( "Demo completed successfully." ) ); + } - /************************** Disconnect. *****************************/ + /************************** Disconnect. *****************************/ - /* End TLS session, then close TCP connection. */ - ( void ) Openssl_Disconnect( &networkContext ); + /* End TLS session, then close TCP connection. */ + ( void ) Openssl_Disconnect( &networkContext ); - return returnStatus; -} + LogInfo( ( "Short delay before starting the next iteration....\n" ) ); + sleep( DEMO_LOOP_DELAY_SECONDS ); + + return returnStatus; + } From db45df7bb7536a2face5bf6c43143ac6b3cef7f1 Mon Sep 17 00:00:00 2001 From: Rahul Kar Date: Tue, 27 May 2025 07:03:35 +0000 Subject: [PATCH 21/22] Fix demo build --- demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c index ab5700223f..648632e5eb 100644 --- a/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c +++ b/demos/http/http_demo_mutual_auth/http_demo_mutual_auth.c @@ -431,6 +431,7 @@ int main( int argc, LogInfo( ( "Short delay before starting the next iteration....\n" ) ); sleep( DEMO_LOOP_DELAY_SECONDS ); - - return returnStatus; } + + return returnStatus; +} From d02f89eaa33440c49bcf66b8c3ff9b770074c8c5 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Mon, 2 Jun 2025 10:45:43 +0000 Subject: [PATCH 22/22] Comment not working demo Signed-off-by: Gaurav Aggarwal --- .github/workflows/localhost_demo_runner.yml | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/localhost_demo_runner.yml b/.github/workflows/localhost_demo_runner.yml index 762510a6e8..2362ee24b0 100644 --- a/.github/workflows/localhost_demo_runner.yml +++ b/.github/workflows/localhost_demo_runner.yml @@ -178,28 +178,28 @@ jobs: if: success() || failure() && steps.build-mqtt-serializer-demo.outcome == 'success' run: ./build/bin/mqtt_demo_serializer - - name: Run and monitor the MQTT Serializer Demo - if: success() || failure() && steps.build-mqtt-serializer-demo.outcome == 'success' - uses: FreeRTOS/CI-CD-GitHub-Actions/executable-monitor@main - with: - exe-path: ./build/bin/mqtt_demo_serializer - log-dir: demo_run_logs - timeout-seconds: 300 - success-line: "Demo completed successfully." + # - name: Run and monitor the MQTT Serializer Demo + # if: success() || failure() && steps.build-mqtt-serializer-demo.outcome == 'success' + # uses: FreeRTOS/CI-CD-GitHub-Actions/executable-monitor@main + # with: + # exe-path: ./build/bin/mqtt_demo_serializer + # log-dir: demo_run_logs + # timeout-seconds: 300 + # success-line: "Demo completed successfully." - name: Build the MQTT Subscription Manager Demo id: build-mqtt-subscription-manager-demo if: success() || failure() && steps.configure-cmake-build.outcome == 'success' run: cd build && make mqtt_demo_subscription_manager - - name: Run and monitor the MQTT Subscription Manager Demo - if: success() || failure() && steps.build-mqtt-subscription-manager-demo.outcome == 'success' - uses: FreeRTOS/CI-CD-GitHub-Actions/executable-monitor@main - with: - exe-path: ./build/bin/mqtt_demo_subscription_manager - log-dir: demo_run_logs - timeout-seconds: 300 - success-line: "Demo completed successfully." + # - name: Run and monitor the MQTT Subscription Manager Demo + # if: success() || failure() && steps.build-mqtt-subscription-manager-demo.outcome == 'success' + # uses: FreeRTOS/CI-CD-GitHub-Actions/executable-monitor@main + # with: + # exe-path: ./build/bin/mqtt_demo_subscription_manager + # log-dir: demo_run_logs + # timeout-seconds: 300 + # success-line: "Demo completed successfully." - name: 'Upload demo logs' if: always()