@@ -48,6 +48,7 @@ WiFiClientSecure::WiFiClientSecure()
48
48
WiFiClientSecure::WiFiClientSecure (int sock)
49
49
{
50
50
_connected = false ;
51
+ _timeout = 0 ;
51
52
52
53
sslclient = new sslclient_context;
53
54
ssl_init (sslclient);
@@ -98,21 +99,34 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port)
98
99
return connect (ip, port, _CA_cert, _cert, _private_key);
99
100
}
100
101
102
+ int WiFiClientSecure::connect (IPAddress ip, uint16_t port, int32_t timeout){
103
+ _timeout = timeout;
104
+ return connect (ip, port);
105
+ }
106
+
101
107
int WiFiClientSecure::connect (const char *host, uint16_t port)
102
108
{
103
109
if (_pskIdent && _psKey)
104
110
return connect (host, port, _pskIdent, _psKey);
105
111
return connect (host, port, _CA_cert, _cert, _private_key);
106
112
}
107
113
114
+ int WiFiClientSecure::connect (const char *host, uint16_t port, int32_t timeout){
115
+ _timeout = timeout;
116
+ return connect (host, port);
117
+ }
118
+
108
119
int WiFiClientSecure::connect (IPAddress ip, uint16_t port, const char *_CA_cert, const char *_cert, const char *_private_key)
109
120
{
110
121
return connect (ip.toString ().c_str (), port, _CA_cert, _cert, _private_key);
111
122
}
112
123
113
124
int WiFiClientSecure::connect (const char *host, uint16_t port, const char *_CA_cert, const char *_cert, const char *_private_key)
114
125
{
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 );
116
130
_lastError = ret;
117
131
if (ret < 0 ) {
118
132
log_e (" start_ssl_client: %d" , ret);
@@ -129,7 +143,10 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent,
129
143
130
144
int WiFiClientSecure::connect (const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
131
145
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);
133
150
_lastError = ret;
134
151
if (ret < 0 ) {
135
152
log_e (" start_ssl_client: %d" , ret);
0 commit comments