EasyManua.ls Logo

Espressif Systems ESP8266EX - Compiling, Downloading, and Debugging; 4.1. Set Up the Compiling Environment

Espressif Systems ESP8266EX
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
!
3. Sample Codes
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
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals