]> git.ipfire.org Git - thirdparty/postgresql.git/commit
ssl: Replace deprecated API to get commonName
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 29 Jul 2026 19:14:18 +0000 (21:14 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 29 Jul 2026 19:14:18 +0000 (21:14 +0200)
commit54dee94e6a71817877dfdeb2c2c811330e58e754
tree9dcb872b4a326b3ef632a2c86fbb564d8e2442c5
parent05d6b5afdf0fbd0b114534081f05f072584bec8c
ssl: Replace deprecated API to get commonName

X509_NAME_get_text_by_NID was deprecated in OpenSSL 4.0.0, and could
be removed in a future version of OpenSSL.  The replacement APIs are
available in all versions of OpenSSL and LibreSSL that we support so
we can easily change to make the code future proof.

The reason for the deprecation is that X509_NAME_get_text_by_NID can
only grab the first entry in a list, and doesn't handle multibyte
strings well.  The fix is to get the index of the name entry with
X509_NAME_get_index_by_NID and use X509_NAME_get_entry to extract
the data.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tristan Partin <tristan@partin.io>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Yilin Zhang <jiezhilove@126.com>
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se
src/backend/libpq/be-secure-openssl.c