@@ -51,8 +51,7 @@ class ESPWifi : public Supla::Network {
51
51
setSsid (wifiSsid);
52
52
setPassword (wifiPassword);
53
53
#ifdef ARDUINO_ARCH_ESP32
54
- enableSSL (
55
- false ); // current ESP32 WiFiClientSecure does not suport "setInsecure"
54
+ enableSSL (false ); // ESP32 WiFiClientSecure does not suport "setInsecure"
56
55
#endif
57
56
}
58
57
@@ -96,22 +95,19 @@ class ESPWifi : public Supla::Network {
96
95
if (client == NULL ) {
97
96
if (isSecured) {
98
97
message = " Secured connection" ;
99
- client = new WiFiClientSecure ();
98
+ auto clientSec = new WiFiClientSecure ();
99
+ client = clientSec;
100
+
101
+ #ifdef ARDUINO_ARCH_ESP8266
102
+ clientSec->setBufferSizes (2048 , 512 ); // EXPERIMENTAL
100
103
if (fingerprint.length () > 0 ) {
101
104
message += " with certificate matching" ;
102
- #ifdef ARDUINO_ARCH_ESP8266
103
- ((WiFiClientSecure *)client)->setFingerprint (fingerprint.c_str ());
104
- #else
105
- message += " - NOT SUPPORTED ON ESP32 implmentation" ;
106
- #endif
105
+ clientSec->setFingerprint (fingerprint.c_str ());
107
106
} else {
108
107
message += " without certificate matching" ;
109
- #ifdef ARDUINO_ARCH_ESP8266
110
- ((WiFiClientSecure *)client)->setInsecure ();
111
- #else
112
- message += " - NOT SUPPORTED ON ESP32 implmentation" ;
113
- #endif
108
+ clientSec->setInsecure ();
114
109
}
110
+ #endif
115
111
} else {
116
112
message = " unsecured connection" ;
117
113
client = new WiFiClient ();
@@ -129,22 +125,8 @@ class ESPWifi : public Supla::Network {
129
125
server,
130
126
connectionPort);
131
127
132
- #ifdef ARDUINO_ARCH_ESP8266
133
- static_cast <WiFiClientSecure*>(client)->setBufferSizes (2048 , 512 ); // EXPERIMENTAL
134
- #endif
135
-
136
128
bool result = client->connect (server, connectionPort);
137
129
138
- // ESP8266 boards 3.0.0 onward do fingerprint check in connect() method.
139
- /* if (result && isSecured) {
140
- if (!((WiFiClientSecure *)client)->verify(fingerprint.c_str(), server)) {
141
- supla_log(LOG_DEBUG, "Provided certificates doesn't match!");
142
- client->stop();
143
- return false;
144
- }
145
- };
146
- */
147
-
148
130
return result;
149
131
}
150
132
0 commit comments