coreHTTP mutual authentication demo
Important
This demo is hosted on the Amazon-FreeRTOS repository which is deprecated. We recommend that you start here when you create a new project. If you already have an existing FreeRTOS project based on the now deprecated Amazon-FreeRTOS repository, see the Amazon-FreeRTOS Github Repository Migration Guide.
Introduction
The coreHTTP (Mutual Authentication) demo project shows you how to establish a connection to an HTTP server using TLS with mutual authentication between the client and the server. This demo uses an mbedTLS-based transport interface implementation to establish a server- and client-authenticated TLS connection, and demonstrates a request response workflow in HTTP.
Note
To set up and run the FreeRTOS demos, follow the steps in Getting Started with FreeRTOS.
Functionality
This demo creates a single application task with examples that show how to complete the following:
-
Connect to the HTTP server on the Amazon IoT endpoint.
-
Send a POST request.
-
Receive the response.
-
Disconnect from the server.
After you complete these steps, the demo generates output similar to the following screenshot.
![Log output showing Amazon IoT demo initialization, TLS session establishment, HTTP POST requests, and memory metrics indicating successful demo completion.](images/coreHTTP.output.png)
The Amazon IoT console generates output similar to the following screenshot.
![Amazon IoT console showing "Hello from Amazon IoT console" message published to a topic on November 20, 2020 at 19:09:09 UTC.](images/coreHTTP.console.png)
Source code organization
The demo source file is named http_demo_mutual_auth.c
and can be found in the
directory and on the
GitHubfreertos
/demos/coreHTTP/
Connecting to the Amazon IoT HTTP server
The
connectToServerWithBackoffRetriesRetryUtils_BackoffAndSleep
function provides exponentially increasing timeout values and returns
RetryUtilsRetriesExhausted
when the maximum number of attempts have been reached. The
connectToServerWithBackoffRetries
function returns a failure status if the TLS connection to
the broker can't be established after the configured number of attempts.
Sending an HTTP request and receiving the response
The
prvSendHttpRequestHTTPClient_Send
.