Connection Issues regarding ESP8266/Node MCU devices

Since ESP8266 2.5.0 core version, the default TLS/SSL client was replaced in the given libraries, as the replaced the axTLS by BearSSL.

This was causing all new flashed devices to prevent the default communication over TLS/SSL, as this library requires now to specify an SSL fingerprint, o explicitly mark the connection as insecure (accept any given server certificate), over setInsecure or setFingerprint methods. So, the only solution was to disable the TLS connection with the _DISABLE_TLS_ define.

So, we have modified the library for supporting this new TLS/SSL client, accepting TLS connections by default. From now on, you can test with the current master version from Github, that will be released very soon as a normal Arduino update. Please, provide us any feedback or comments if you test it!

Thanks! :wink:

#ifndef THINGER_ESP8266_H
#define THINGER_ESP8266_H

#include <ESP8266WiFi.h>
#include "ThingerWifi.h"

#ifndef _DISABLE_TLS_
class ThingerESP8266 : public ThingerWifiClient<WiFiClientSecure>{
#else
class ThingerESP8266 : public ThingerWifiClient<WiFiClient>{
#endif

public:
    ThingerESP8266(const char* user, const char* device, const char* device_credential) :
            ThingerWifiClient(user, device, device_credential)
    {

    }

    ~ThingerESP8266(){

    }

#ifndef _DISABLE_TLS_
protected:
    virtual bool connect_socket(){

    // since CORE 2.5.0, now it is used BearSSL by default
#ifndef _VALIDATE_SSL_CERTIFICATE_
        client_.setInsecure();
        THINGER_DEBUG("SSL/TLS", "Warning: use #define _VALIDATE_SSL_CERTIFICATE_ if certificate validation is required")
#else
        client_.setFingerprint(THINGER_TLS_FINGERPRINT);
        THINGER_DEBUG_VALUE("SSL/TLS", "SHA-1 certificate fingerprint: ", THINGER_TLS_FINGERPRINT)
#endif
        return client_.connect(THINGER_SERVER, THINGER_SSL_PORT);
    }

    virtual bool secure_connection(){
        return true;
    }
#endif

};

#endif