BUG/MEDIUM: ssl: ca-file directory mode must read every certificates of a file next
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 Sep 2025 07:22:55 +0000 (09:22 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Oct 2025 14:48:35 +0000 (16:48 +0200)
commit83805a611b1622c0664846e61549c9f35845f306
tree6ececef379bcecbbbb86965125384949ea3fb9e7
parentd7f11530481231cd2c23a0efa38490079a3aa413
BUG/MEDIUM: ssl: ca-file directory mode must read every certificates of a file

The httpclient is configured with @system-ca by default, which uses the
directory returned by X509_get_default_cert_dir().

On debian/ubuntu systems, this directory contains multiple certificate
files that are loaded successfully. However it seems that on other
systems the files in this directory is the direct result of
ca-certificates instead of its source. Meaning that you would only have
a bundle file with every certificates in it.

The loading was not done correctly in case of directory loading, and was
only loading the first certificate of each file.

This patch fixes the issue by using X509_STORE_load_locations() on each
file from the scandir instead of trying to load it manually with BIO.

Not that we can't use X509_STORE_load_locations with the `dir` argument,
which would be simpler, because it uses X509_LOOKUP_hash_dir() which
requires a directory in hash form. That wouldn't be suited for this use
case.

Must be backported in every stable branches.

Fix issue #3137.

(cherry picked from commit c52d69cc785c039c0b665a229350fff11cfeda13)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit a96a1ef0a48a9b5b3883346bb21c79b95fa653eb)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 8c014f305e7fd6ad9123f38067262c457fbe488f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/ssl_ckch.c