Page 1 of 1

Uploading SSL Certificate to WiFiNiNA-W102 Module using ESP-IDF Issue

Posted: Tue Dec 05, 2023 4:36 am
by TeamVEGA
Hello Everyone,

I am currently facing an issue while attempting to upload an SSL certificate to a WiFiNiNA-W102 Module using ESP-IDF. I have followed the steps below, and I'm encountering a problem where it appears to be erasing the flash memory containing the NiNA firmware.

Steps Taken:

1. Certificate Generation:
I generated the SSL certificate using InfinityFree software online, and I have converted it into the required format.

Code: Select all

openssl x509 -outform DER -in sslcertificate.pem -out server_cert.bin
xxd -i server_cert.bin > server_cert.h
2. ESP-IDF Setup:
I set up the ESP-IDF environment for ESP32 as per the official documentation.

3. Project Configuration:
I created a project with the following main code:

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_http_client.h"
#include "server_cert.h"

extern unsigned char server_cert_bin[];
extern unsigned int server_cert_bin_len;

static const char *TAG = "HTTPS_CLIENT";

void app_main() {
    esp_http_client_config_t config = {
        .url = "https://connectvega.rf.gd",
        .cert_pem = (char *)server_cert_bin,
    };

    esp_http_client_handle_t client = esp_http_client_init(&config);
    esp_err_t err = esp_http_client_perform(client);

    if (err == ESP_OK) {
        ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %lld",
                 esp_http_client_get_status_code(client),
                 esp_http_client_get_content_length(client));
    } else {
        ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err));
    }

    esp_http_client_cleanup(client);

    while (1) {
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}
Concern:

The project builds and uploads successfully, but it seems to be erasing the flash memory where the NiNA firmware is stored.

I am seeking guidance on how to resolve this issue. Any insights or suggestions from the community would be greatly appreciated. Thank you!

Re: Uploading SSL Certificate to WiFiNiNA-W102 Module using ESP-IDF Issue

Posted: Tue Dec 05, 2023 5:03 am
by ESP_Sprite
I mean, yes, the instructions you follow effectively create a new firmware, and if you upload it you'll erase the existing firmware. I am not familiar with the WiFiNiNA firmware, but you need instructions specific to that to upload a certificate that works with it.

Re: Uploading SSL Certificate to WiFiNiNA-W102 Module using ESP-IDF Issue

Posted: Wed Dec 06, 2023 5:30 am
by TeamVEGA
Thank you, @ESP_Sprite, for the clarification. I'll search for the appropriate documentation specific to the WiFiNINA module.