handshake in ssl_client.cpp (#2044)

* issue #2041

* handshake timeout

* seconds to milliseconds
This commit is contained in:
A C SREEDHAR REDDY
2018-11-27 03:55:08 +05:30
committed by Me No Dev
parent 0640964879
commit 46257c03b3
4 changed files with 14 additions and 3 deletions

View File

@ -158,12 +158,14 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
mbedtls_ssl_set_bio(&ssl_client->ssl_ctx, &ssl_client->socket, mbedtls_net_send, mbedtls_net_recv, NULL );
log_v("Performing the SSL/TLS handshake...");
unsigned long handshake_start_time=millis();
while ((ret = mbedtls_ssl_handshake(&ssl_client->ssl_ctx)) != 0) {
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
return handle_error(ret);
}
vTaskDelay(10 / portTICK_PERIOD_MS);
if((millis()-handshake_start_time)>ssl_client->handshake_timeout)
return -1;
vTaskDelay(10 / portTICK_PERIOD_MS);
}