mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-16 10:39:49 +00:00
fix built-in TLS not calling MG_EV_TLS_HS; uniformize mg_tls_init()
This commit is contained in:
1 parent
e7ea421c54
commit
b8b3a5c305
5 files changed
+3
-12
No files matched your search
+1
-6
@@ -11154,6 +11154,7 @@ static void mg_tls_client_handshake(struct mg_connection *c) {
|
||||
}
|
||||
tls->state = MG_TLS_STATE_CLIENT_CONNECTED;
|
||||
c->is_tls_hs = 0;
|
||||
mg_call(c, MG_EV_TLS_HS, NULL);
|
||||
break;
|
||||
default:
|
||||
mg_error(c, "unexpected client state: %d", tls->state);
|
||||
@@ -12912,9 +12913,6 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
c->is_tls_hs = 1;
|
||||
mbedtls_ssl_set_bio(&tls->ssl, c, mg_net_send, mg_net_recv, 0);
|
||||
MG_PROF_ADD(c, "mbedtls_init_end");
|
||||
if (c->is_client && c->is_resolving == 0 && c->is_connecting == 0) {
|
||||
mg_tls_handshake(c);
|
||||
}
|
||||
return;
|
||||
fail:
|
||||
mg_tls_free(c);
|
||||
@@ -13212,9 +13210,6 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
|
||||
c->is_tls = 1;
|
||||
c->is_tls_hs = 1;
|
||||
if (c->is_client && c->is_resolving == 0 && c->is_connecting == 0) {
|
||||
mg_tls_handshake(c);
|
||||
}
|
||||
MG_DEBUG(("%lu SSL %s OK", c->id, c->is_accepted ? "accept" : "client"));
|
||||
return;
|
||||
fail:
|
||||
|
||||
@@ -1193,6 +1193,7 @@ static void mg_tls_client_handshake(struct mg_connection *c) {
|
||||
}
|
||||
tls->state = MG_TLS_STATE_CLIENT_CONNECTED;
|
||||
c->is_tls_hs = 0;
|
||||
mg_call(c, MG_EV_TLS_HS, NULL);
|
||||
break;
|
||||
default:
|
||||
mg_error(c, "unexpected client state: %d", tls->state);
|
||||
|
||||
@@ -164,9 +164,6 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
c->is_tls_hs = 1;
|
||||
mbedtls_ssl_set_bio(&tls->ssl, c, mg_net_send, mg_net_recv, 0);
|
||||
MG_PROF_ADD(c, "mbedtls_init_end");
|
||||
if (c->is_client && c->is_resolving == 0 && c->is_connecting == 0) {
|
||||
mg_tls_handshake(c);
|
||||
}
|
||||
return;
|
||||
fail:
|
||||
mg_tls_free(c);
|
||||
|
||||
@@ -229,9 +229,6 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
|
||||
c->is_tls = 1;
|
||||
c->is_tls_hs = 1;
|
||||
if (c->is_client && c->is_resolving == 0 && c->is_connecting == 0) {
|
||||
mg_tls_handshake(c);
|
||||
}
|
||||
MG_DEBUG(("%lu SSL %s OK", c->id, c->is_accepted ? "accept" : "client"));
|
||||
return;
|
||||
fail:
|
||||
|
||||
@@ -31,6 +31,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
struct mg_tls_opts opts = {.ca = mg_unpacked("/certs/ca.pem"),
|
||||
.name = mg_url_host(server)};
|
||||
mg_tls_init(c, &opts);
|
||||
mg_tls_handshake(c); // speed up, not strictly necessary
|
||||
*state = AUTH;
|
||||
} else if (*state == AUTH) {
|
||||
char a[100], b[300] = "";
|
||||
|
||||
Reference in new issue
Block a user