Skip to content

feature: support lua_ssl_key_log and ssl.export_keying_material() with BoringSSL. - #2543

Open
h2zi wants to merge 2 commits into
openresty:masterfrom
h2zi:boringssl-keylog-exporter
Open

h2zi wants to merge 2 commits into
openresty:masterfrom
h2zi:boringssl-keylog-exporter

Conversation

@h2zi

@h2zi h2zi commented Nov 2, 2026

Copy link
Copy Markdown

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

Two SSL features were disabled for BoringSSL although BoringSSL provides the APIs they need, in both the build CI uses (boringssl-20230902) and current BoringSSL:

  • lua_ssl_key_log: BoringSSL always reports OPENSSL_VERSION_NUMBER as 1.1.1, so the > 1.1.1j check left HAVE_SSL_KEY_LOG undefined. The directive was accepted but silently did nothing. BoringSSL has provided SSL_CTX_set_keylog_callback() for a long time.
  • ngx_http_lua_ffi_ssl_export_keying_material() (ssl.export_keying_material() in lua-resty-core) returned "BoringSSL does not support SSL_export_keying_material". BoringSSL provides SSL_export_keying_material() with the same signature as OpenSSL. Only SSL_export_keying_material_early() is missing, so that function still refuses, now naming the right function. Old OpenSSL versions also got the BoringSSL message from both functions; they now get "OpenSSL too old".

The lua_ssl_key_log test in t/129-ssl-socket.t matched the secrets in the order OpenSSL writes them. BoringSSL writes them in a different order, and the key log file is appended to on every repeated request. The test now keeps the lines of the last handshake (by client random) and sorts them before matching.

Testing

On Ubuntu 22.04 (aarch64), nginx 1.31.8 built with util/build.sh:

  • OpenSSL 3.5.5 with OpenResty's patch: t/129-ssl-socket.t, t/139-ssl-cert-by.t, t/140-ssl-c-api.t, t/142, t/143, t/155, t/162, t/166, t/169, t/170-*, t/187, t/193, t/194 all pass. lua-resty-core's t/ssl.t, t/ocsp.t, t/ssl-*.t, t/proxy-ssl*.t and t/stream/ssl.t also pass against this build.
  • BoringSSL 6ca49385 (2023-09-01, the commit behind boringssl-20230902), without HTTP/3: t/129-ssl-socket.t TEST 35 (lua_ssl_key_log) and lua-resty-core's t/ssl.t TEST 31 (export_keying_material) now pass. The other failures in these two files (BoringSSL is not run without HTTP/3 in CI) are the same before and after this change.
  • Current BoringSSL main, without HTTP/3: t/129-ssl-socket.t TEST 35 passes as well.

The CI BoringSSL job runs with TEST_NGINX_USE_HTTP3, which skips t/129-ssl-socket.t. The export_keying_material test is in lua-resty-core, which has no BoringSSL job. So CI does not exercise either change with BoringSSL.

CI on master currently fails to build ngx_http_lua_shdict.c (since bdd4cad); this branch is based on ab14673, the last green commit.

Related: openresty/openresty#1159 (I came across these while looking into AWS-LC support).

🤖 Generated with Claude Code

h2zi and others added 2 commits November 3, 2026 05:02
BoringSSL always reports OPENSSL_VERSION_NUMBER as 1.1.1, so the version
check left HAVE_SSL_KEY_LOG undefined and the directive was accepted but
silently ignored, although BoringSSL has long provided
SSL_CTX_set_keylog_callback().

The lua_ssl_key_log test now checks the secrets of the last handshake
only, in sorted order: the key log file is appended to on every request,
and BoringSSL logs the secrets in a different order than OpenSSL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BoringSSL provides SSL_export_keying_material() with the same signature
as OpenSSL; only SSL_export_keying_material_early() is missing.

Also, old OpenSSL versions got "BoringSSL does not support
SSL_export_keying_material" from both functions instead of "OpenSSL too
old", and BoringSSL now gets the right function name for the early one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant