@@ -124,12 +124,21 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, int32_t timeout){
124124
125125int WiFiClientSecure::connect (IPAddress ip, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
126126{
127- return connect (ip. toString (). c_str () , port, CA_cert, cert, private_key);
127+ return connect (ip, port, NULL , CA_cert, cert, private_key);
128128}
129129
130130int WiFiClientSecure::connect (const char *host, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
131131{
132- int ret = start_ssl_client (sslclient, host, port, _timeout, CA_cert, _use_ca_bundle, cert, private_key, NULL , NULL , _use_insecure, _alpn_protos);
132+ IPAddress address;
133+ if (!WiFi.hostByName (host, address))
134+ return 0 ;
135+
136+ return connect (address, port, host, CA_cert, cert, private_key);
137+ }
138+
139+ int WiFiClientSecure::connect (IPAddress ip, uint16_t port, const char *host, const char *CA_cert, const char *cert, const char *private_key)
140+ {
141+ int ret = start_ssl_client (sslclient, ip, port, host, _timeout, CA_cert, _use_ca_bundle, cert, private_key, NULL , NULL , _use_insecure, _alpn_protos);
133142 _lastError = ret;
134143 if (ret < 0 ) {
135144 log_e (" start_ssl_client: %d" , ret);
@@ -146,7 +155,12 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent,
146155
147156int WiFiClientSecure::connect (const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
148157 log_v (" start_ssl_client with PSK" );
149- int ret = start_ssl_client (sslclient, host, port, _timeout, NULL , false , NULL , NULL , pskIdent, psKey, _use_insecure, _alpn_protos);
158+
159+ IPAddress address;
160+ if (!WiFi.hostByName (host, address))
161+ return 0 ;
162+
163+ int ret = start_ssl_client (sslclient, address, port, host, _timeout, NULL , false , NULL , NULL , pskIdent, psKey, _use_insecure, _alpn_protos);
150164 _lastError = ret;
151165 if (ret < 0 ) {
152166 log_e (" start_ssl_client: %d" , ret);
0 commit comments