]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MAJOR: jwt: Allow certificate instead of public key in jwt_verify converter
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Mon, 30 Jun 2025 14:56:26 +0000 (16:56 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 30 Jun 2025 15:59:55 +0000 (17:59 +0200)
commit522bca98e14385beaf0b06a4f711777ba1aab933
tree043458d15873d84c503cd2f2c5f7312447ba4625
parent6e9f886c4dc0ccdb6f5fbddb450a0af4ec901004
MAJOR: jwt: Allow certificate instead of public key in jwt_verify converter

The 'jwt_verify' converter could only be passed public keys as second
parameter instead of full-on public certificates. This patch allows
proper certificates to be used.
Those certificates can be loaded in ckch_stores like any other
certificate which means that all the certificate-related operations that
can be made via the CLI can now benefit JWT validation as well.

We now have two ways JWT validation can work, the legacy one which only
relies on public keys which could not be stored in ckch_stores without
some in depth changes in the way the ckch_stores are built. In this
legacy way, the public keys are fully stored in a cache dedicated to JWT
only which does not have any CLI commands and any way to update them
during runtime. It also requires that all the public keys used are
passed at least once explicitely to the 'jwt_verify' converter so that
they can be loaded during init.
The new way uses actual certificates, either already stored in the
ckch_store tree (if predefined in a crt-store or already used previously
in the configuration) or loaded in the ckch_store tree during init if
they are explicitely used in the configuration like so:
    var(txn.bearer),jwt_verify(txn.jwt_alg,"cert.pem")

When using a variable (or any other way that can only be resolved during
runtime) in place of the converter's <key> parameter, the first time we
encounter a new value (for which we don't have any entry in the jwt
tree) we will lock the ckch_store tree and try to perform a lookup in
it. If the lookup fails, an entry will still be inserted into the jwt
tree so that any following call with this value avoids performing the
ckch_store tree lookup.
include/haproxy/jwt-t.h
include/haproxy/jwt.h
include/haproxy/ssl_ckch-t.h
include/haproxy/thread-t.h
src/jwt.c
src/sample.c
src/ssl_ckch.c
src/thread.c