BUG/MEDIUM: ssl: chosing correct certificate using RSA-PSS with TLSv1.3
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 7 Feb 2025 19:28:39 +0000 (20:28 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 11 Feb 2025 09:07:41 +0000 (10:07 +0100)
commiteddd48e50156acb17344e60fa882aa2304694126
treee58f34772025dec0f30399dacec16bdbcab866df
parent6036c3186be49b621b3fafc096d7103c3452fa5e
BUG/MEDIUM: ssl: chosing correct certificate using RSA-PSS with TLSv1.3

The clienthello callback was written when TLSv1.3 was not yet out, and
signatures algorithm changed since then.

With TLSv1.2, the least significant byte was used to determine the
SignatureAlgorithm, which could be rsa(1), dsa(2), ecdsa(3).
https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.4.1

This was used to chose which type of certificate to push to the client.

But TLSv1.3 changed that, and introduced new RSA-PSS algorithms that
does not have the least sinificant byte to 1.
https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.3

This would result in chosing the wrong certificate when an RSA an ECDSA
ones are in the configuration for the same SNI or default entry.

This patch fixes the issue by parsing bothe hash and signature field to
check the RSA-PSS signature scheme.

This must fix issue #2852.

This must be backported in every stable versions. The code was moved
from ssl_sock.c to ssl_clienthello in recent versions.

(cherry picked from commit 64502715968fb12f446fcb6432a5431d803d8935)
[wla: moved the code in ssl_sock.c]
Signed-off-by: William Lallemand <wlallemand@haproxy.com>
src/ssl_sock.c