@@ -124,12 +124,21 @@ int WiFiClientSecure::connect(const char *host, uint16_t port, int32_t timeout){
124
124
125
125
int WiFiClientSecure::connect (IPAddress ip, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
126
126
{
127
- return connect (ip. toString (). c_str () , port, CA_cert, cert, private_key);
127
+ return connect (ip, port, NULL , CA_cert, cert, private_key);
128
128
}
129
129
130
130
int WiFiClientSecure::connect (const char *host, uint16_t port, const char *CA_cert, const char *cert, const char *private_key)
131
131
{
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);
133
142
_lastError = ret;
134
143
if (ret < 0 ) {
135
144
log_e (" start_ssl_client: %d" , ret);
@@ -146,7 +155,12 @@ int WiFiClientSecure::connect(IPAddress ip, uint16_t port, const char *pskIdent,
146
155
147
156
int WiFiClientSecure::connect (const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
148
157
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);
150
164
_lastError = ret;
151
165
if (ret < 0 ) {
152
166
log_e (" start_ssl_client: %d" , ret);
0 commit comments