Cope with a deficiency in OpenSSL 3.x's error reporting.
authorTom Lane <[email protected]>
Fri, 8 Mar 2024 00:37:51 +0000 (19:37 -0500)
committerTom Lane <[email protected]>
Fri, 8 Mar 2024 00:37:51 +0000 (19:37 -0500)
commit473babd4290e88a6d01b52f19dc0ec54e3fbcd73
tree99a57e664371c828dce16f240d21293f389bf0ef
parent49b971298a9b4271a9d5f91dcc969c5cb1acfbc1
Cope with a deficiency in OpenSSL 3.x's error reporting.

In OpenSSL 3.0.0 and later, ERR_reason_error_string randomly refuses
to provide a string for error codes representing system errno values
(e.g., "No such file or directory").  There is a poorly-documented way
to extract the errno from the SSL error code in this case, so do that
and apply strerror, rather than falling back to reporting the error
code's numeric value as we were previously doing.

Problem reported by David Zhang, although this is not his proposed
patch; it's instead based on a suggestion from Heikki Linnakangas.
Back-patch to all supported branches, since any of them are likely
to be used with recent OpenSSL.

Discussion: https://postgr.es/m/b6fb018b-f05c-4afd-abd3-318c649faf18@highgo.ca
src/backend/libpq/be-secure-openssl.c
src/interfaces/libpq/fe-secure-openssl.c