mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-25 12:04:47 +00:00
Restore tickets support
This commit is contained in:
1 parent
9055a83b4f
commit
9ec48e41f7
9 files changed
+120
-16
No files matched your search
+32
-8
@@ -144,14 +144,9 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
}
|
||||
|
||||
#ifdef MBEDTLS_SSL_SESSION_TICKETS
|
||||
mbedtls_ssl_ticket_init(&tls->ticket);
|
||||
if ((rc = mbedtls_ssl_ticket_setup(&tls->ticket, mg_mbed_rng, NULL,
|
||||
MBEDTLS_CIPHER_AES_128_GCM, 86400)) != 0) {
|
||||
mg_error(c, " mbedtls_ssl_ticket_setup %#x", -rc);
|
||||
goto fail;
|
||||
}
|
||||
mbedtls_ssl_conf_session_tickets_cb(&tls->conf, mbedtls_ssl_ticket_write,
|
||||
mbedtls_ssl_ticket_parse, &tls->ticket);
|
||||
mbedtls_ssl_conf_session_tickets_cb(
|
||||
&tls->conf, mbedtls_ssl_ticket_write, mbedtls_ssl_ticket_parse,
|
||||
&((struct mg_tls_ctx *) c->mgr->tls_ctx)->tickets);
|
||||
#endif
|
||||
|
||||
if ((rc = mbedtls_ssl_setup(&tls->ssl, &tls->conf)) != 0) {
|
||||
@@ -191,4 +186,33 @@ long mg_tls_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
if (n <= 0) return MG_IO_ERR;
|
||||
return n;
|
||||
}
|
||||
|
||||
void mg_tls_ctx_init(struct mg_mgr *mgr) {
|
||||
struct mg_tls_ctx *ctx = (struct mg_tls_ctx *) calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
MG_ERROR(("TLS context init OOM"));
|
||||
} else {
|
||||
#ifdef MBEDTLS_SSL_SESSION_TICKETS
|
||||
int rc;
|
||||
mbedtls_ssl_ticket_init(&ctx->tickets);
|
||||
if ((rc = mbedtls_ssl_ticket_setup(&ctx->tickets, mg_mbed_rng, NULL,
|
||||
MBEDTLS_CIPHER_AES_128_GCM, 86400)) !=
|
||||
0) {
|
||||
MG_ERROR((" mbedtls_ssl_ticket_setup %#x", -rc));
|
||||
}
|
||||
#endif
|
||||
mgr->tls_ctx = ctx;
|
||||
}
|
||||
}
|
||||
|
||||
void mg_tls_ctx_free(struct mg_mgr *mgr) {
|
||||
struct mg_tls_ctx *ctx = (struct mg_tls_ctx *) mgr->tls_ctx;
|
||||
if (ctx != NULL) {
|
||||
#ifdef MBEDTLS_SSL_SESSION_TICKETS
|
||||
mbedtls_ssl_ticket_free(&ctx->tickets);
|
||||
#endif
|
||||
free(ctx);
|
||||
mgr->tls_ctx = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user