Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation issues for esp32dev environment: net.getLastSSLError() #14

Open
gitolicious opened this issue Jul 17, 2020 · 0 comments
Open

Comments

@gitolicious
Copy link

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

Serial.println(net.getLastSSLError());

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

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:

#ifdef ESP8266
      Serial.println(net.getLastSSLError());
#else
      char *errorMessage;
      int errorCode = net.lastError(errorMessage, 2048);
      Serial.println(errorCode);
      Serial.println(errorMessage);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant