@@ -48,6 +48,7 @@ WiFiClientSecure::WiFiClientSecure()
4848WiFiClientSecure::WiFiClientSecure (int  sock)
4949{
5050    _connected = false ;
51+     _timeout = 0 ;
5152
5253    sslclient = new  sslclient_context;
5354    ssl_init (sslclient);
@@ -98,21 +99,34 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port)
9899    return  connect (ip, port, _CA_cert, _cert, _private_key);
99100}
100101
102+ int  WiFiClientSecure::connect (IPAddress ip, uint16_t  port, int32_t  timeout){
103+     _timeout = timeout;
104+     return  connect (ip, port);
105+ }
106+ 
101107int  WiFiClientSecure::connect (const  char  *host, uint16_t  port)
102108{
103109    if  (_pskIdent && _psKey)
104110        return  connect (host, port, _pskIdent, _psKey);
105111    return  connect (host, port, _CA_cert, _cert, _private_key);
106112}
107113
114+ int  WiFiClientSecure::connect (const  char  *host, uint16_t  port, int32_t  timeout){
115+     _timeout = timeout;
116+     return  connect (host, port);
117+ }
118+ 
108119int  WiFiClientSecure::connect (IPAddress ip, uint16_t  port, const  char  *_CA_cert, const  char  *_cert, const  char  *_private_key)
109120{
110121    return  connect (ip.toString ().c_str (), port, _CA_cert, _cert, _private_key);
111122}
112123
113124int  WiFiClientSecure::connect (const  char  *host, uint16_t  port, const  char  *_CA_cert, const  char  *_cert, const  char  *_private_key)
114125{
115-     int  ret = start_ssl_client (sslclient, host, port, _CA_cert, _cert, _private_key, NULL , NULL );
126+     if (_timeout > 0 ){
127+         sslclient->handshake_timeout  = _timeout * 1000 ;
128+     }
129+     int  ret = start_ssl_client (sslclient, host, port, _timeout, _CA_cert, _cert, _private_key, NULL , NULL );
116130    _lastError = ret;
117131    if  (ret < 0 ) {
118132        log_e (" start_ssl_client: %d" 
@@ -129,7 +143,10 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent,
129143
130144int  WiFiClientSecure::connect (const  char  *host, uint16_t  port, const  char  *pskIdent, const  char  *psKey) {
131145    log_v (" start_ssl_client with PSK" 
132-     int  ret = start_ssl_client (sslclient, host, port, NULL , NULL , NULL , _pskIdent, _psKey);
146+     if (_timeout > 0 ){
147+         sslclient->handshake_timeout  = _timeout * 1000 ;
148+     }
149+     int  ret = start_ssl_client (sslclient, host, port, _timeout, NULL , NULL , NULL , _pskIdent, _psKey);
133150    _lastError = ret;
134151    if  (ret < 0 ) {
135152        log_e (" start_ssl_client: %d" 
0 commit comments