Skip to content

Instantly share code, notes, and snippets.

@alex-tomin
alex-tomin / Readme.md
Created September 12, 2023 02:15
How to Debug TLS/SSL session for ESP8266 with Wireshark

How to Debug TLS/SSL session for ESP8266 (WiFiClientSecure) with Wireshark

Check this link for ESP32

Modify WiFiClientSecureBearSSL.h to write secrets

if you develop via PlatformIO you cna find the file C:\Users\<user>\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.h If you are using VSCode - it can navigate to sources nicely.

  1. Move *_eng declaration to public section for WiFiClientSecureCtx class
@alex-tomin
alex-tomin / MyWiFiClientSecure.h
Last active September 12, 2023 02:17
How to Debug TLS/SSL session for ESP32 with Wireshark
#include <WiFiClientSecure.h>
int export_keys(void *p_expkey, const unsigned char *p_master, const unsigned char *kb,
size_t maclen, size_t keylen, size_t ivlen,
const unsigned char client_random[32], const unsigned char p_server_random[32], mbedtls_tls_prf_types tls_prf_type)
{
Serial.println(" ------SSLKEYLOGFILE Format------------ ");
Serial.print("CLIENT_RANDOM ");
for (size_t i = 0; i < 32; i++)
@alex-tomin
alex-tomin / Readme.md
Last active January 16, 2024 12:40
ESP Home - Connect to MQTT with x509 Client Certificate. (Azure Event Grid)

ESPHome: Connecting to Secure MQTT Server from esp 8266 / esp32

In this example I tried to Connect to Azure Event Grid. Which worked in MQTTX (you can download the tool here), but ESP Home does not support it out of the box. See esphome/feature-requests#1019

This example receives a json message in the following format and converts values to few sensors.

{
  "IncidentId": "1234456",
  "Team":"HardWorkers",
 "Title":"Power Loss",