Repository navigation
fix(consul): upgrade lua-resty-consul to 0.4.0 - #14118
Merged
Merged
Conversation
lua-resty-consul 0.3.2 connects through the plain host:port connection pool and skips the TLS handshake when it gets a reused connection. Two registries pointing at the same https consul server therefore share their connections, and one with ssl_verify could send its queries over a connection set up by another without certificate verification. 0.4.0 connects with the table form of lua-resty-http connect, which keys the pool on the scheme, the SNI and the ssl_verify setting, so only connections established with the same TLS options are reused.
AlinsRan
force-pushed
the
fix/consul-tls-pool-key
branch
from
October 28, 2026 09:29
a69bd9e to
fbb2021
Compare
nic-6443
approved these changes
Oct 29, 2026
shreemaan-abhishek
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The consul discovery client sends its queries through
resty.consul. Version 0.3.2 connects withhttpc:connect(host, port), which uses the defaulthost:portconnection pool, and then callsssl_handshake, which returns immediately on a reused connection. When two consul registries point at the same https server, one withssl_verify: falseand one withssl_verify: true, the verifying registry can pick up a pooled connection the other one set up without certificate verification, and fetch nodes from a server whose certificate it would reject.lua-resty-consul 0.4.0 connects with the table form of
lua-resty-httpconnect(scheme,host,port,ssl_verify,ssl_server_name). That form puts the scheme, SNI andssl_verifyinto the pool name and does the handshake itself, so a connection is reused only by a client with the same TLS options. This PR bumps the dependency to0.4-0.Other changes in 0.4.0 to
lib/resty/consul.lua: none besides the connect rewrite (the rest of the release is CI, test certificates and the README). Its dependency list is unchanged (lua-resty-http, unversioned), and the table form ofconnectis available in thelua-resty-httpversion APISIX already ships. The callers,discovery/consulanddiscovery/consul_kv, always pass a host and port, so the unix socket path (no port) that the connect rewrite affects is not used.Test:
t/discovery/consul-tls.tTEST 7 runs the default registry withssl_verify: falseand a second registry withssl_verify: trueagainst the same https endpoint, whose certificate is not trusted. With 0.3.2 the second registry resolves the service; with 0.4.0 it fails certificate verification. The other consul / consul_kv discovery tests give the same results with both versions.The PR also fixes a startup race in TEST 2-5 of the same file: they sent
GET /helloright after nginx started, before the privileged agent's first consul fetch, and could get a 503 or miss the expected error log. The/helloroute now has aserverless-pre-functionthat waits until the shared dict has the service (up to 5 seconds, for the test where the fetch is expected to fail).Which issue(s) this PR fixes:
N/A
Checklist