postgresql/src/backend/libpq
Tom Lane efb8046827 Use BIO_{get,set}_app_data instead of BIO_{get,set}_data.
We should have done it this way all along, but we accidentally got
away with using the wrong BIO field up until OpenSSL 3.2.  There,
the library's BIO routines that we rely on use the "data" field
for their own purposes, and our conflicting use causes assorted
weird behaviors up to and including core dumps when SSL connections
are attempted.  Switch to using the approved field for the purpose,
i.e. app_data.

While at it, remove our configure probes for BIO_get_data as well
as the fallback implementation.  BIO_{get,set}_app_data have been
there since long before any OpenSSL version that we still support,
even in the back branches.

Also, update src/test/ssl/t/001_ssltests.pl to allow for a minor
change in an error message spelling that evidently came in with 3.2.

Tristan Partin and Bo Andreson.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAN55FZ1eDDYsYaL7mv+oSLUij2h_u6hvD4Qmv-7PK7jkji0uyQ@mail.gmail.com
2023-11-28 12:34:03 -05:00
..
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
README.SSL Move EDH support to common files 2018-01-23 07:11:38 -05:00
auth-scram.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
auth.c Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:32 -04:00
be-fsstubs.c Fix snapshot reference leak if lo_export fails. 2021-11-03 10:54:36 +02:00
be-gssapi-common.c Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:32 -04:00
be-secure-common.c Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
be-secure-gssapi.c Fix timing-dependent failure in GSSAPI data transmission. 2023-11-23 13:30:18 -05:00
be-secure-openssl.c Use BIO_{get,set}_app_data instead of BIO_{get,set}_data. 2023-11-28 12:34:03 -05:00
be-secure.c Fix assorted issues in backend's GSSAPI encryption support. 2020-12-28 17:44:17 -05:00
crypt.c Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
hba.c Raise fixed token-length limit in hba.c. 2023-07-27 12:07:48 -04:00
ifaddr.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_hba.conf.sample gss: add missing references to hostgssenc and hostnogssenc 2020-05-25 20:19:28 -04:00
pg_ident.conf.sample Reformat the comments in pg_hba.conf and pg_ident.conf 2010-01-26 06:58:39 +00:00
pqcomm.c Revert "graceful shutdown" changes for Windows, in back branches only. 2022-01-25 12:17:40 -05:00
pqformat.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pqmq.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pqsignal.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00

README.SSL

src/backend/libpq/README.SSL

SSL
===

>From the servers perspective:


  Receives StartupPacket
           |
           |
 (Is SSL_NEGOTIATE_CODE?) -----------  Normal startup
           |                  No
           |
           | Yes
           |
           |
 (Server compiled with USE_SSL?) ------- Send 'N'
           |                       No        |
           |                                 |
           | Yes                         Normal startup
           |
           |
        Send 'S'
           |
           |
      Establish SSL
           |
           |
      Normal startup





>From the clients perspective (v6.6 client _with_ SSL):


      Connect
         |
         |
  Send packet with SSL_NEGOTIATE_CODE
         |
         |
  Receive single char  ------- 'S' -------- Establish SSL
         |                                       |
         | '<else>'                              |
         |                                  Normal startup
         |
         |
   Is it 'E' for error  ------------------- Retry connection
         |                  Yes             without SSL
         | No
         |
   Is it 'N' for normal ------------------- Normal startup
         |                  Yes
         |
   Fail with unknown

---------------------------------------------------------------------------

Ephemeral DH
============

Since the server static private key ($DataDir/server.key) will
normally be stored unencrypted so that the database backend can
restart automatically, it is important that we select an algorithm
that continues to provide confidentiality even if the attacker has the
server's private key.  Ephemeral DH (EDH) keys provide this and more
(Perfect Forward Secrecy aka PFS).

N.B., the static private key should still be protected to the largest
extent possible, to minimize the risk of impersonations.

Another benefit of EDH is that it allows the backend and clients to
use DSA keys.  DSA keys can only provide digital signatures, not
encryption, and are often acceptable in jurisdictions where RSA keys
are unacceptable.

The downside to EDH is that it makes it impossible to use ssldump(1)
if there's a problem establishing an SSL session.  In this case you'll
need to temporarily disable EDH (see initialize_dh()).