FreeRTOS: HTTPS Client
HTTPS Client v1.0.0 library
Return to main page ↑
Download Demo Usage Instructions
  1. Ensure that you have permissions in your AWS account to access S3.
    For information on AWS S3 please see: https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html
  2. In an existing bucket or creating a new bucket upload the following file:
    gettysburg.txt
  3. Install and configured the AWS CLI.
    For AWS CLI installation information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
    For AWS CLI configuration information please see: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
  4. Run demos/https/presigned_url_gen.py with your s3 bucket-name and s3 object key object-key.

    python presigned_url_gen.py --bucket my-bucket --key object-key

    Please see demos/https/README.md for information on the required Python version and Python package dependencies.

    Example output:

    #define IOT_DEMO_HTTPS_PRESIGNED_GET_URL https://aws-s3-endpoint/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D
    #define IOT_DEMO_HTTPS_PRESIGNED_PUT_URL https://aws-s3-endpoint/object-key.txt?AWSAccessKeyId=ABABABABABABABABABAB&Expires=1560555644&Signature=SomeHash12345UrlLMnmOPqrStUvW

    Paste this output to iot_config.h.

    Note:
    If your bucket is less than 24 hours old, then you will need to append the region the bucket was created in to the pre-signed URL:

    https://my-bucket.s3-<region>.amazonaws.com/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D

    Example:

    https://my-bucket.s3-us-west-2.amazonaws.com/object-key.txt?AWSAccessKeyId=AAAAAAAAAAAAAAAAAAAA&Expires=1560555644&Signature=SomeHash12345UrlABcdEFgfIjK%3D

    Please see https://aws.amazon.com/premiumsupport/knowledge-center/s3-http-307-response/ for more information.

  5. Paste your RSA-2048 or ECC-P256 keys into aws_clientcredential_keys.h. This is needed to for the TLS handshake with the AWS S3 HTTP Server.
  6. Enable the Synchronous download demo by defining CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED in aws_demo_config.h:
    /* To run a particular demo you need to define one of these.
    * Only one demo can be configured at a time
    *
    * CONFIG_MQTT_DEMO_ENABLED
    * CONFIG_SHADOW_DEMO_ENABLED
    * CONFIG_GREENGRASS_DISCOVERY_DEMO_ENABLED
    * CONFIG_TCP_ECHO_CLIENT_DEMO_ENABLED
    * CONFIG_DEFENDER_DEMO_ENABLED
    * CONFIG_POSIX_DEMO_ENABLED
    * CONFIG_OTA_UPDATE_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
    *
    * These defines are used in iot_demo_runner.h for demo selection */
    #define CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED
  7. See Building the demo applications for instructions on building the demo.
    A successful output looks like this:
    10 618 [iot_thread] [INFO ][INIT][618] SDK successfully initialized.
    11 618 [iot_thread] [INFO ][DEMO][618] Successfully initialized the demo. Network type for the demo: 4
    12 618 [iot_thread] [INFO ][DEMO][618] HTTPS Client Synchronous S3 download demo using pre-signed URL: https://sarem-public.s3.amazonaws.com/gettysburg.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&X-Amz-Credential=AKIAIYLZ53PYH6JY77YQ%2F20190830%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Date=20190830T171845Z&X-Amz-Signature=2b185273a920fe10b0bbf5a391c9af8af7caf0d76170eade4fd99f28d3a68a00
    13 902 [iot_thread] [INFO ][DEMO][902] Now requesting Range: bytes=0-511.
    14 942 [iot_thread] [INFO ][DEMO][942] Response return code: 206
    15 942 [iot_thread] [INFO ][DEMO][942] Response Body:
    Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
    Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altoge
    16 942 [iot_thread] [INFO ][DEMO][942] Downloaded 512/1517
    17 942 [iot_thread] [INFO ][DEMO][942] Now requesting Range: bytes=512-1023.
    18 1003 [iot_thread] [INFO ][DEMO][1003] Response return code: 206
    19 1003 [iot_thread] [INFO ][DEMO][1003] Response Body:
    ther fitting and proper that we should do this.
    But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly adv
    20 1003 [iot_thread] [INFO ][DEMO][1003] Downloaded 1024/1517
    21 1003 [iot_thread] [INFO ][DEMO][1003] Now requesting Range: bytes=1024-1516.
    22 1063 [iot_thread] [INFO ][DEMO][1063] Response return code: 206
    23 1063 [iot_thread] [INFO ][DEMO][1063] Response Body:
    anced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.
    Abraham Lincoln
    November 19, 1863
    24 1063 [iot_thread] [INFO ][DEMO][1063] Downloaded 1517/1517
    25 1102 [iot_thread] [INFO ][DEMO][1102] Demo completed successfully.
    26 1105 [iot_thread] [INFO ][INIT][1105] SDK cleanup done.
  8. Enable the Asynchronous download demo by defining either CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED in aws_demo_config.h:
    /* To run a particular demo you need to define one of these.
    * Only one demo can be configured at a time
    *
    * CONFIG_MQTT_DEMO_ENABLED
    * CONFIG_SHADOW_DEMO_ENABLED
    * CONFIG_GREENGRASS_DISCOVERY_DEMO_ENABLED
    * CONFIG_TCP_ECHO_CLIENT_DEMO_ENABLED
    * CONFIG_DEFENDER_DEMO_ENABLED
    * CONFIG_POSIX_DEMO_ENABLED
    * CONFIG_OTA_UPDATE_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_SYNC_UPLOAD_DEMO_ENABLED
    * CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED
    *
    * These defines are used in iot_demo_runner.h for demo selection */
    #define CONFIG_HTTPS_ASYNC_DOWNLOAD_DEMO_ENABLED
  9. See Building the demo applications for instructions on building the demo.
    A successful output looks like this:

    10 632 [iot_thread] [INFO ][INIT][632] SDK successfully initialized.
    11 632 [iot_thread] [INFO ][DEMO][632] Successfully initialized the demo. Network type for the demo: 4
    12 632 [iot_thread] [INFO ][DEMO][632] HTTPS Client Asynchronous S3 download demo using pre-signed URL: https://sarem-public.s3.amazonaws.com/gettysburg.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&X-Amz-Credential=AKIAIYLZ53PYH6JY77YQ%2F20190830%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Date=20190830T171845Z&X-Amz-Signature=2b185273a920fe10b0bbf5a391c9af8af7caf0d76170eade4fd99f28d3a68a00
    13 915 [iot_thread] [INFO ][DEMO][915] Inside of the append header callback for part bytes=0-511
    14 954 [NetRecv] [INFO ][DEMO][954] Inside of the read ready callback for part bytes=0-511 with network return code: 0
    15 954 [NetRecv] [INFO ][DEMO][954] Response return code: 206 for bytes=0-511
    16 954 [NetRecv] [INFO ][DEMO][954] Response Body for bytes=0-511:
    Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
    Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altoge
    17 954 [iot_thread] [INFO ][DEMO][954] Inside of the append header callback for part bytes=512-1023
    18 954 [NetRecv] [INFO ][DEMO][954] Part bytes=0-511 has been fully processed.
    19 954 [NetRecv] [INFO ][DEMO][954] Downloaded: 512/1517
    20 1014 [NetRecv] [INFO ][DEMO][1014] Inside of the read ready callback for part bytes=512-1023 with network return code: 0
    21 1014 [NetRecv] [INFO ][DEMO][1014] Response return code: 206 for bytes=512-1023
    22 1014 [NetRecv] [INFO ][DEMO][1014] Response Body for bytes=512-1023:
    ther fitting and proper that we should do this.
    But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly adv
    23 1014 [iot_thread] [INFO ][DEMO][1014] Inside of the append header callback for part bytes=1024-1516
    24 1014 [NetRecv] [INFO ][DEMO][1014] Part bytes=512-1023 has been fully processed.
    25 1014 [NetRecv] [INFO ][DEMO][1014] Downloaded: 1024/1517
    26 1074 [NetRecv] [INFO ][DEMO][1074] Inside of the read ready callback for part bytes=1024-1516 with network return code: 0
    27 1074 [NetRecv] [INFO ][DEMO][1074] Response return code: 206 for bytes=1024-1516
    28 1074 [NetRecv] [INFO ][DEMO][1074] Response Body for bytes=1024-1516:
    anced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.
    Abraham Lincoln
    November 19, 1863
    29 1074 [NetRecv] [INFO ][DEMO][1074] Part bytes=1024-1516 has been fully processed.
    30 1074 [NetRecv] [INFO ][DEMO][1074] Downloaded: 1517/1517
    31 1114 [iot_thread] [INFO ][DEMO][1114] Demo completed successfully.
    32 1116 [iot_thread] [INFO ][INIT][1116] SDK cleanup done.

Notes:
Please note that the buffer for printing may be smaller than 512 characters and the printed received response body may be truncated.

"[NetRecv] [WARN ][NET][2977] Receive requested 768 bytes, but 400 bytes received instead." is OK because the library requests from the network interface the full size of the header buffer or body buffer.

S3 will close the connection after 100 requests on the same connection.