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 <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Reviewed-by: Andreas Karlsson <[email protected]>
Reviewed-by: Yilin Zhang <[email protected]>
Discussion: https://postgr.es/m/[email protected]

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(-)

Reply via email to