Skip to content

tls: openssl: add runtime enable/disable API for SSL key logging#3556

Open
VaibhavTekale1 wants to merge 38 commits into
warmcat:mainfrom
VaibhavTekale1:feat/sslkeylogging-runtime-enable-disable
Open

tls: openssl: add runtime enable/disable API for SSL key logging#3556
VaibhavTekale1 wants to merge 38 commits into
warmcat:mainfrom
VaibhavTekale1:feat/sslkeylogging-runtime-enable-disable

Conversation

@VaibhavTekale1
Copy link
Copy Markdown

@VaibhavTekale1 VaibhavTekale1 commented Mar 17, 2026

@lws-team

Summary

Add two new public APIs to enable and disable SSL key logging (SSLKEYLOGFILE)
at runtime, without requiring a context rebuild.

Previously, the keylog callback was only registered if keylog_file was set
at context creation time (lws_context_creation_info). This made it impossible
to toggle key logging on an already-running context.

Changes

New public APIs (include/libwebsockets/lws-context-vhost.h)

  • lws_set_keylog_file(struct lws *wsi, char *sslkeyfilepath)
    Enables SSL key logging. If sslkeyfilepath is non-empty, that path is used;
    otherwise the SSLKEYLOGFILE environment variable is consulted. The resolved
    path is written into wsi->a.context->keylog_file.

  • lws_reset_keylog_file(struct lws *wsi)
    Disables SSL key logging by clearing wsi->a.context->keylog_file.

TLS callback registration (lib/tls/openssl/)

  • openssl-client.c, openssl-server.c: SSL_CTX_set_keylog_callback() is
    now registered unconditionally (subject to LWS_HAVE_SSL_CTX_set_keylog_callback
    and LWS_WITH_TLS). The lws_klog_dump callback itself gates on whether
    keylog_file is set, so logging only occurs when explicitly enabled via the
    new APIs.

  • Simplified the preprocessor condition in openssl-server.c from
    (!defined(LWS_WITHOUT_CLIENT) || !defined(LWS_WITHOUT_SERVER)) to just
    defined(LWS_WITH_TLS), which is the meaningful guard for this code path.

lws-team added 30 commits March 14, 2026 18:01
Add a generic DTLS wrapper to lws that is able to work using any of the
supported tls libraries as the backed: openssl (and variants), mbedtls,
gnutls, schannel

Note that schannel is not able to work with webrtc due to schannel api's
own limitations.  You must use openssl or mbedtls for windows if you want
to use dtls for webrtc.
This adds support for webrtc serving along with ALSA, OPUS, V4L2, TRANSCODE
and other critical pieces
Having added a member to lws_plugin_protocol, it's a good time to change
the old struct initializer format to C9, since we'll have to visit them all
anyway.

Also modernize the event lib struct while we're at it.
Various things that Sai identified needed fixing
@lws-team lws-team force-pushed the main branch 17 times, most recently from c0616c1 to d15a153 Compare May 14, 2026 12:32
@lws-team lws-team force-pushed the main branch 13 times, most recently from 8e57b3d to a686094 Compare May 20, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants