Fix HTTP Client with SSL (#3216)

This commit is contained in:
Me No Dev 2019-09-16 19:14:32 +03:00 committed by GitHub
parent 07390157df
commit 4ce2cc3c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -28,7 +28,15 @@
class WiFiClientSocketHandle; class WiFiClientSocketHandle;
class WiFiClientRxBuffer; class WiFiClientRxBuffer;
class WiFiClient : public Client class ESPLwIPClient : public Client
{
public:
virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
virtual int setTimeout(uint32_t seconds) = 0;
};
class WiFiClient : public ESPLwIPClient
{ {
protected: protected:
std::shared_ptr<WiFiClientSocketHandle> clientSocketHandle; std::shared_ptr<WiFiClientSocketHandle> clientSocketHandle;

View File

@ -72,6 +72,8 @@ public:
bool verify(const char* fingerprint, const char* domain_name); bool verify(const char* fingerprint, const char* domain_name);
void setHandshakeTimeout(unsigned long handshake_timeout); void setHandshakeTimeout(unsigned long handshake_timeout);
int setTimeout(uint32_t seconds){ return 0; }
operator bool() operator bool()
{ {
return connected(); return connected();

View File

@ -22,7 +22,7 @@
const char *pers = "esp32-tls"; const char *pers = "esp32-tls";
static int handle_error(int err) static int _handle_error(int err, const char * file, int line)
{ {
if(err == -30848){ if(err == -30848){
return err; return err;
@ -30,12 +30,15 @@ static int handle_error(int err)
#ifdef MBEDTLS_ERROR_C #ifdef MBEDTLS_ERROR_C
char error_buf[100]; char error_buf[100];
mbedtls_strerror(err, error_buf, 100); mbedtls_strerror(err, error_buf, 100);
log_e("%s", error_buf); log_e("[%s():%d]: (%d) %s", file, line, err, error_buf);
#else
log_e("[%s():%d]: code %d", file, line, err);
#endif #endif
log_e("MbedTLS message code: %d", err);
return err; return err;
} }
#define handle_error(e) _handle_error(e, __FUNCTION__, __LINE__)
void ssl_init(sslclient_context *ssl_client) void ssl_init(sslclient_context *ssl_client)
{ {