debsahu / debsahu/ESP-MQTT-AWS-IoT-Core

Compilation issues for esp32dev environment: net.getLastSSLError()

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
118
Forks
50
PR merge metrics
No merged PRs in 30d

Description

When compiling a fresh checkout for ESP32 (esp32dev), I am getting the following error:

> Compiling .pio\build\esp32dev\lib694\WiFi\WiFiGeneric.cpp.o
.../ESP-MQTT-AWS-IoT-Core/Arduino/MQTT/MQTT.ino: In function 'void connectToMqtt(bool)':
.../ESP-MQTT-AWS-IoT-Core/Arduino/MQTT/MQTT.ino:133:26: error: 'class WiFiClientSecure' has no member named 'getLastSSLError'
Serial.println(net.getLastSSLError());

The offending line
https://github.com/debsahu/ESP-MQTT-AWS-IoT-Core/blob/64817e28b0a7ca295af926a6c352a9b4d51ee15e/Arduino/MQTT/MQTT.ino#L133

is referring to code that is only available in the ESP8266 WiFiClientSecure (BearSSL) implementation:

https://github.com/esp8266/Arduino/blob/c3c61a5f751fcc75440e571b5aa89254dce6e4f7/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h#L115-L116

```
// Return an error code and possibly a text string in a passed-in buffer with last SSL failure
int getLastSSLError(char *dest = NULL, size_t len = 0);
```

For ESP32, BearSSL is not used (not available). Would `net.lastError()` be the correct alternative?

https://github.com/espressif/arduino-esp32/blob/b92c58d74b151c7a3b56db4e78f2d3c90c16446f/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp#L322-L331

```c++
int WiFiClientSecure::lastError(char *buf, const size_t size)
{
if (!_lastError) {
return 0;
}
char error_buf[100];
mbedtls_strerror(_lastError, error_buf, 100);
snprintf(buf, size, "%s", error_buf);
return _lastError;
}
```
If so, then the implementation could work like this:
```c++
#ifdef ESP8266
Serial.println(net.getLastSSLError());
#else
char *errorMessage;
int errorCode = net.lastError(errorMessage, 2048);
Serial.println(errorCode);
Serial.println(errorMessage);
#endif
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.