postgresql/src/backend/libpq
Tom Lane 3ed2005ff5 Introduce macros for typalign and typstorage constants.
Our usual practice for "poor man's enum" catalog columns is to define
macros for the possible values and use those, not literal constants,
in C code.  But for some reason lost in the mists of time, this was
never done for typalign/attalign or typstorage/attstorage.  It's never
too late to make it better though, so let's do that.

The reason I got interested in this right now is the need to duplicate
some uses of the TYPSTORAGE constants in an upcoming ALTER TYPE patch.
But in general, this sort of change aids greppability and readability,
so it's a good idea even without any specific motivation.

I may have missed a few places that could be converted, and it's even
more likely that pending patches will re-introduce some hard-coded
references.  But that's not fatal --- there's no expectation that
we'd actually change any of these values.  We can clean up stragglers
over time.

Discussion: https://postgr.es/m/16457.1583189537@sss.pgh.pa.us
2020-03-04 10:34:25 -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 Remove excess parens in ereport() calls 2020-01-30 13:32:04 -03:00
auth.c Clean up some code, comments and docs referring to Windows 2000 and older 2020-02-19 13:20:33 +09:00
be-fsstubs.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
be-gssapi-common.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
be-secure-common.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
be-secure-gssapi.c Extensive code review for GSSAPI encryption mechanism. 2020-01-11 17:14:08 -05:00
be-secure-openssl.c Remove excess parens in ereport() calls 2020-01-30 13:32:04 -03:00
be-secure.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
crypt.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
hba.c Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
ifaddr.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_hba.conf.sample Rename "scram" to "scram-sha-256" in pg_hba.conf and password_encryption. 2017-04-18 14:50:50 +03: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 Assume that we have utime() and <utime.h>. 2020-02-21 14:30:47 -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()).