From a54b62d77794dee48510e7c128d3ab2fc90934b3 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 21 Apr 2021 09:05:56 -0700 Subject: vcl session: refactor passing of crypto context Pass tls/quic crypto context using extended config instead of bloating conect/listen messages. Type: refactor Signed-off-by: Florin Coras Change-Id: I0bc637ae310e6c31ef1e16847501dcb81453ee94 --- src/plugins/http_static/static_server.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/plugins/http_static/static_server.c') diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index b354666f816..23860b083d8 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -1185,6 +1185,13 @@ http_static_server_attach () return 0; } +static int +http_static_transport_needs_crypto (transport_proto_t proto) +{ + return proto == TRANSPORT_PROTO_TLS || proto == TRANSPORT_PROTO_DTLS || + proto == TRANSPORT_PROTO_QUIC; +} + static int http_static_server_listen () { @@ -1192,6 +1199,7 @@ http_static_server_listen () session_endpoint_cfg_t sep = SESSION_ENDPOINT_CFG_NULL; vnet_listen_args_t _a, *a = &_a; char *uri = "tcp://0.0.0.0/80"; + int rv; clib_memset (a, 0, sizeof (*a)); a->app_index = hsm->app_index; @@ -1203,9 +1211,17 @@ http_static_server_listen () return -1; clib_memcpy (&a->sep_ext, &sep, sizeof (sep)); - a->sep_ext.ckpair_index = hsm->ckpair_index; + if (http_static_transport_needs_crypto (a->sep_ext.transport_proto)) + { + session_endpoint_alloc_ext_cfg (&a->sep_ext, + TRANSPORT_ENDPT_EXT_CFG_CRYPTO); + a->sep_ext.ext_cfg->crypto.ckpair_index = hsm->ckpair_index; + } - return vnet_listen (a); + rv = vnet_listen (a); + if (a->sep_ext.ext_cfg) + clib_mem_free (a->sep_ext.ext_cfg); + return rv; } static void -- cgit 1.2.3-korg