]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: jwt: Use only JWT cert tree for jwt_verify
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 18 Nov 2026 14:09:30 +0000 (15:09 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 20 Nov 2026 09:02:42 +0000 (09:02 +0000)
commit607222c3569ba136d34ff44f3df2f67971db2f7e
tree327ace74e6ee1a4b12904e47aae126ffc6850448
parent620a94b8f496f3f476c62e5d1b97ef826f9bfad8
BUG/MEDIUM: jwt: Use only JWT cert tree for jwt_verify

The jwt_verify converter can either used a public key that was already
stored in a dedicated tree built during init that did not require any
lock, or use a certificate loaded in the ckch_store tree. The main issue
in this second case is that we needed to take the ckch_lock during
runtime but this spinlock is also taken during all CLI commands that
modify the certificates (and can last a long time when a lot of chck
instances are rebuilt for instance).

We now store the public keys used by jwt_verify in the JWT certificate
tree for all code paths instead of looking them up in the CKCH tree. We
keep the tree entry in sync when certificates are loaded, replaced,
removed, or when the "jwt" option is toggled through the CLI. In those
cases, the lock on the JWT tree in only taken while the tree gets
updated, during the ckch_store_replace call.

A keyless entry is also created for certificates whose "jwt" option is
disabled so that jwt_verify can still report JWT_VRFY_UNAVAIL_CERT (-7)
instead of JWT_VRFY_UNKNOWN_CERT (-5).

This patch relies on "MINOR: jwt: Add rwlock to jwt_cert_tree".  It
fixes the issue described in GitHub #3526 (and raised by some IA models
as well).

This patch can be backported up to 3.3.
include/haproxy/jwt-t.h
include/haproxy/jwt.h
src/jwt.c
src/ssl_ckch.c