Skip to content

bugfix: lua_ssl_verify_depth and lua_ssl_certificate* were not initialized without proxy SSL support. - #416

Open
h2zi wants to merge 1 commit into
openresty:masterfrom
h2zi:fix-ssl-conf-init
Open

h2zi wants to merge 1 commit into
openresty:masterfrom
h2zi:fix-ssl-conf-init

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 stream-lua-nginx-module project.

ngx_stream_lua_create_srv_conf() initialized ssl_verify_depth, ssl_certificates and ssl_certificate_keys only inside #ifdef HAVE_LUA_PROXY_SSL. That macro is defined only for OpenSSL 3.0.2 or later. The lua_ssl_verify_depth, lua_ssl_certificate and lua_ssl_certificate_key directives are registered in every build.

With BoringSSL, LibreSSL or OpenSSL older than 3.0.2, the fields were left at 0 from ngx_pcalloc(), so:

  • lua_ssl_verify_depth was always rejected: "lua_ssl_verify_depth" directive is duplicate;
  • without it, the verify depth for cosockets defaulted to 0 instead of 1;
  • lua_ssl_certificate and lua_ssl_certificate_key set in the stream {} block were not inherited by servers, because ngx_conf_merge_ptr_value() only inherits from NGX_CONF_UNSET_PTR.

This change initializes them whenever NGX_STREAM_SSL is set, as ngx_http_lua_create_loc_conf() does with NGX_HTTP_SSL. ups.upstream_skip_openssl_default_verify stays under HAVE_LUA_PROXY_SSL, because its directive only exists there.

Testing

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

  • With BoringSSL (6ca49385, the commit behind the boringssl-20230902 build used by lua-nginx-module's CI, and current main): before this change, t/129-ssl-socket.t and t/139-ssl-cert-by.t bailed out because nginx could not start, with the duplicate-directive error above. With this change both files run to completion. Some BoringSSL-specific failures remain in them. Those tests were not reached before, and the failures are unrelated to this change; for example, they expect OpenSSL's "cert cb error" text.
  • With OpenSSL 3.5.5 with OpenResty's patch, t/129, t/139, t/140, t/162–t/167, t/170 and t/171 all pass. Nothing changes there, because HAVE_LUA_PROXY_SSL is defined.

This repository's CI only builds with OpenSSL 3, so the bug does not show up there.

CI on master currently fails to build ngx_stream_lua_shdict.c (since 68949e1); this branch is based on 9bc2e1f, the last green commit.

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

🤖 Generated with Claude Code

…lized without proxy SSL support.

The srv conf initialized ssl_verify_depth, ssl_certificates and
ssl_certificate_keys only when HAVE_LUA_PROXY_SSL was defined, that is,
with OpenSSL 3.0.2 or later, while the lua_ssl_verify_depth,
lua_ssl_certificate and lua_ssl_certificate_key directives are always
available. With BoringSSL, LibreSSL or older OpenSSL versions the fields
stayed zero, so lua_ssl_verify_depth was always rejected as a duplicate
directive, the verify depth of cosockets defaulted to 0 instead of 1,
and lua_ssl_certificate* were not inherited from the stream {} block.

Initialize them whenever SSL is enabled, as ngx_http_lua_module does.

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