Skip to content

Commit 4ce2cc3

Browse files
authored
Fix HTTP Client with SSL (#3216)
1 parent 0739015 commit 4ce2cc3

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

libraries/WiFi/src/WiFiClient.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
class WiFiClientSocketHandle;
2929
class WiFiClientRxBuffer;
3030

31-
class WiFiClient : public Client
31+
class ESPLwIPClient : public Client
32+
{
33+
public:
34+
virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
35+
virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
36+
virtual int setTimeout(uint32_t seconds) = 0;
37+
};
38+
39+
class WiFiClient : public ESPLwIPClient
3240
{
3341
protected:
3442
std::shared_ptr<WiFiClientSocketHandle> clientSocketHandle;

libraries/WiFiClientSecure/src/WiFiClientSecure.h

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class WiFiClientSecure : public WiFiClient
7272
bool verify(const char* fingerprint, const char* domain_name);
7373
void setHandshakeTimeout(unsigned long handshake_timeout);
7474

75+
int setTimeout(uint32_t seconds){ return 0; }
76+
7577
operator bool()
7678
{
7779
return connected();

libraries/WiFiClientSecure/src/ssl_client.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,23 @@
2222

2323
const char *pers = "esp32-tls";
2424

25-
static int handle_error(int err)
25+
static int _handle_error(int err, const char * file, int line)
2626
{
2727
if(err == -30848){
2828
return err;
2929
}
3030
#ifdef MBEDTLS_ERROR_C
3131
char error_buf[100];
3232
mbedtls_strerror(err, error_buf, 100);
33-
log_e("%s", error_buf);
33+
log_e("[%s():%d]: (%d) %s", file, line, err, error_buf);
34+
#else
35+
log_e("[%s():%d]: code %d", file, line, err);
3436
#endif
35-
log_e("MbedTLS message code: %d", err);
3637
return err;
3738
}
3839

40+
#define handle_error(e) _handle_error(e, __FUNCTION__, __LINE__)
41+
3942

4043
void ssl_init(sslclient_context *ssl_client)
4144
{

0 commit comments

Comments
 (0)