pgsql: ssl: Replace deprecated API to get commonName

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: ssl: Replace deprecated API to get commonName
Date: 2026-07-29 19:27:35
Message-ID: E1wp9wF-00000000qIu-1aKv@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)yesql(dot)se>
Reviewed-by: Tristan Partin <tristan(at)partin(dot)io>
Reviewed-by: Andreas Karlsson <andreas(at)proxel(dot)se>
Reviewed-by: Yilin Zhang <jiezhilove(at)126(dot)com>
Discussion: https://postgr.es/m/68B9881D-DAA8-467D-A251-C96E98E57BA0@yesql.se

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/54dee94e6a71817877dfdeb2c2c811330e58e754

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-07-29 19:55:53 pgsql: doc: Add a note that refint will be removed in v20
Previous Message Bruce Momjian 2026-07-29 18:20:56 pgsql: doc: remove added space within synopsis replaceable tags