Merge branch 'master' of github.com:cesanta/mongoose

This commit is contained in:
cpq 2021-04-09 16:55:16 +01:00
commit 5430408218
2 changed files with 12 additions and 8 deletions

View File

@ -3593,9 +3593,10 @@ int mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
mbedtls_ssl_conf_ca_chain(&tls->conf, &tls->ca, NULL);
#endif
if (opts->srvname.len > 0) {
char buf[opts->srvname.len + 1];
sprintf(buf, "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
char mem[128], *buf = mem;
mg_asprintf(&buf, sizeof(mem), "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
mbedtls_ssl_set_hostname(&tls->ssl, buf);
if (buf != mem) free(buf);
}
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
}
@ -3768,9 +3769,10 @@ int mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
}
if (opts->ciphers != NULL) SSL_set_cipher_list(tls->ssl, opts->ciphers);
if (opts->srvname.len > 0) {
char buf[opts->srvname.len + 1];
sprintf(buf, "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
char mem[128], *buf = mem;
mg_asprintf(&buf, sizeof(mem), "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
SSL_set_tlsext_host_name(tls->ssl, buf);
if (buf != mem) free(buf);
}
c->tls = tls;
c->is_tls = 1;

View File

@ -117,9 +117,10 @@ int mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
mbedtls_ssl_conf_ca_chain(&tls->conf, &tls->ca, NULL);
#endif
if (opts->srvname.len > 0) {
char buf[opts->srvname.len + 1];
sprintf(buf, "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
char mem[128], *buf = mem;
mg_asprintf(&buf, sizeof(mem), "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
mbedtls_ssl_set_hostname(&tls->ssl, buf);
if (buf != mem) free(buf);
}
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_REQUIRED);
}
@ -292,9 +293,10 @@ int mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
}
if (opts->ciphers != NULL) SSL_set_cipher_list(tls->ssl, opts->ciphers);
if (opts->srvname.len > 0) {
char buf[opts->srvname.len + 1];
sprintf(buf, "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
char mem[128], *buf = mem;
mg_asprintf(&buf, sizeof(mem), "%.*s", (int) opts->srvname.len, opts->srvname.ptr);
SSL_set_tlsext_host_name(tls->ssl, buf);
if (buf != mem) free(buf);
}
c->tls = tls;
c->is_tls = 1;