1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Make SNI host name an ssl_client_new argument

ssl_set_hostname was mostly useless, because it allowed setting host name of an existing SSL object. However SNI was sent as part of client_hello, which was done in ssl_client_new. So it wasn't possible to actually set host name before connection would start.
This commit is contained in:
Ivan Grokhotkov
2016-04-19 07:56:22 +03:00
parent 5b4be7d273
commit fe4518da8d
3 changed files with 8 additions and 35 deletions

View File

@ -251,6 +251,7 @@ EXP_FUNC void STDCALL ssl_free(SSL *ssl)
disposable_free(ssl);
certificate_free(ssl);
free(ssl->bm_all_data);
free(ssl->host_name);
free(ssl);
}
@ -1876,29 +1877,6 @@ EXP_FUNC int STDCALL ssl_get_config(int offset)
}
}
/**
* Sets the SNI hostname
*/
EXP_FUNC int STDCALL ssl_set_hostname(SSL *ssl, const char* host_name) {
if(host_name == NULL || strlen(host_name) == 0 || strlen(host_name) > 255 ) {
return 0;
}
if(ssl->host_name != NULL) {
free(ssl->host_name);
}
ssl->host_name = (char *)malloc(strlen(host_name)+1);
if(ssl->host_name == NULL) {
// most probably there was no memory available
return 0;
}
strcpy(ssl->host_name, host_name);
return 1;
}
#ifdef CONFIG_SSL_CERT_VERIFICATION
/**
* Authenticate a received certificate.