!
printf("heap_size %d\n",system_get_free_heap_size());
6. When the SSL authentication function is required:
If not using SPIFFS file system, please run python script esp_iot_sdk_freertos\tools\
•
make_cert.py, generate esp_ca_cert.bin, and write it into the flash.
Below is an example showing how to read information about the SSL encryption key
and certificate from the flash.
uint8 flash_offset = 0x78; // Example : Flash address 0x78000
if (ssl_obj_option_load(ssl_ctx, SSL_OBJ_RSA_KEY, "XX.key", password, flash_offset)){
printf("Error: the Private key is undefined.\n");
}
if (ssl_obj_option_load(ssl_ctx, SSL_OBJ_X509_CERT, "XX.cer", NULL, flash_offset)){
printf("Error: the Certificate is undefined.\n");
}
If using SPIFFS file system, please run the tool spiffy (https://github.com/xlfe/spiffy.
•
Please note that the spiffs_config.h of this tool has to be the same as the one in the
RTOS SDK). Then generate spiffs_rom.bin, and write it into the flash; for details on
this process please refer to the example of esp_spiffs_init.
Below is an example showing how to read information about the SSL encryption key
and certificate from the flash using SPIFFS.
if (ssl_obj_load(ssl_ctx, SSL_OBJ_RSA_KEY, "XX.key", password)){
printf("Error: the Private key is undefined.\n");
}
if (ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CERT, "XX.cer", NULL)){
printf("Error: the Certificate is undefined.\n");
}
7. Start a handshake with the SSL client.
ssl = ssl_client_new(ssl_ctx, client_fd, NULL, 0);
if (ssl != NULL){
printf("client handshake start\n");
}
8. Check the status of the SSL connection.
if ((res = ssl_handshake_status(ssl)) == SSL_OK){
... ...
}
9. If the handshake is successful, then the certificate can be released and more memory
space will be available.
Espressif
32 37
!
/!
3. Sample Codes
2017.05
Need help?
Do you have a question about the ESP8266EX and is the answer not in the manual?
Questions and answers