Yes that’s what I was asking for, thanks! But, I still have a few more questions.
So as an update, I created a certificate using AWS IoT Core and added those so a configuration file. Please note, this is for my custom project so I’m not using the HTTPS demo code.
As well, I was able to successfully upload to an S3 bucket using a python script from my computer Python AWS example. What I’m confused about is how to do the same on my ESP32.
Here is the code I implemented once I have access to a wi-fi connection:
void send_http_request(void *arg){
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
IotHttpsClient_Init();
// An initialized network interface.
IotNetworkInterface_t* pNetworkInterface = &IotNetworkAfr;
// Parameters to HTTPS Client connect.
IotHttpsConnectionInfo_t connInfo = IOT_HTTPS_CONNECTION_INFO_INITIALIZER;
IotHttpsConnectionHandle_t connHandle = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER;
uint8_t* pConnUserBuffer = (uint8_t*)malloc(connectionUserBufferMinimumSize);
// Set the connection configuration information.
connInfo.pAddress = "www.amazon.com";
connInfo.addressLen = strlen("www.amazon.com");
connInfo.port = 443;
connInfo.flags = 0;
connInfo.pAlpnProtocols = "x-amzn-http-ca";
connInfo.pCaCert = HTTPS_TRUSTED_ROOT_CA;
connInfo.caCertLen = sizeof( HTTPS_TRUSTED_ROOT_CA );
connInfo.userBuffer.pBuffer = pConnUserBuffer;
connInfo.userBuffer.bufferLen = connectionUserBufferMinimumSize;
connInfo.pClientCert = keyCLIENT_CERTIFICATE_PEM;
connInfo.clientCertLen = sizeof( keyCLIENT_CERTIFICATE_PEM );
connInfo.pPrivateKey = keyCLIENT_PRIVATE_KEY_PEM;
connInfo.privateKeyLen = sizeof( keyCLIENT_PRIVATE_KEY_PEM );
connInfo.pNetworkInterface = pNetworkInterface;
IotHttpsReturnCode_t returnCode = IotHttpsClient_Connect(&connHandle, &connInfo);
if( returnCode == IOT_HTTPS_OK )
{
// Do something with the HTTPS connection...
// Clean up and close the HTTPS connection once it's no longer needed.
IotHttpsClient_Disconnect(connHandle);
}
for(;;){}
}
but the code crashes and outputs the following:
I (4694) WIFI_TASK: SYSTEM_EVENT_STA_GOT_IP:192.168.7.104
../amazon-freertos/freertos_kernel/queue.c:1429 (xQueueSemaphoreTake)- assert failed!
abort() was called at PC 0x40088dbf on core 0
xtensa-esp32-elf-addr2line -pfiaC -e /Users/verajparuthi/esp/Pebble_ESP32_Firmware/build/esp32_app 0x40088dbf: [Errno 2] No such file or directory
ELF file SHA256: a493ea87a4267066ee586a53f0e2d303cb9b52e1797a12988562db47c0778a34
Backtrace: 0x40087c0c:0x3ffb4b20 0x40087e39:0x3ffb4b40 0x40088dbf:0x3ffb4b60 0x4012b4d5:0x3ffb4ba0 0x40128bf1:0x3ffb4bc0 0x40127e7c:0x3ffb4bf0 0x40121ef4:0x3ffb4c20 0x401227a2:0x3ffb4e80 0x400dd612:0x3ffb4ea0
I used the following values for constants:
#define HTTPS_TRUSTED_ROOT_CA \
"-----BEGIN CERTIFICATE-----\n" \
"MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" \
"RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" \
"VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" \
"DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" \
"ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" \
"VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" \
"mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" \
"IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" \
"mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" \
"XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" \
"dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" \
"jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" \
"BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" \
"DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" \
"9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" \
"jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" \
"Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" \
"ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" \
"R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" \
"-----END CERTIFICATE-----\n"
and
/**
* @brief An #IotNetworkInterface_t that uses the functions in this file.
*/
const IotNetworkInterface_t IotNetworkAfr =
{
.create = IotNetworkAfr_Create,
.setReceiveCallback = IotNetworkAfr_SetReceiveCallback,
.send = IotNetworkAfr_Send,
.receive = IotNetworkAfr_Receive,
.receiveUpto = IotNetworkAfr_ReceiveUpto,
.close = IotNetworkAfr_Close,
.destroy = IotNetworkAfr_Destroy
};
which is defined in ./amazon-freertos/libraries/abstractions/platform/freertos/iot_network_freertos.c
Please advise. Thanks!
Notes
This is for ESP32 and I am on the latest AWSFreeRTOS version.