postgresql/src/bin/psql
Bruce Momjian a9bd17616e Attached are a revised set of SSL patches. Many of these patches
are motivated by security concerns, it's not just bug fixes.  The key
differences (from stock 7.2.1) are:

*) almost all code that directly uses the OpenSSL library is in two
   new files,

     src/interfaces/libpq/fe-ssl.c
     src/backend/postmaster/be-ssl.c

   in the long run, it would be nice to merge these two files.

*) the legacy code to read and write network data have been
   encapsulated into read_SSL() and write_SSL().  These functions
   should probably be renamed - they handle both SSL and non-SSL
   cases.

   the remaining code should eliminate the problems identified
   earlier, albeit not very cleanly.

*) both front- and back-ends will send a SSL shutdown via the
   new close_SSL() function.  This is necessary for sessions to
   work properly.

   (Sessions are not yet fully supported, but by cleanly closing
   the SSL connection instead of just sending a TCP FIN packet
   other SSL tools will be much happier.)

*) The client certificate and key are now expected in a subdirectory
   of the user's home directory.  Specifically,

	- the directory .postgresql must be owned by the user, and
	  allow no access by 'group' or 'other.'

	- the file .postgresql/postgresql.crt must be a regular file
	  owned by the user.

	- the file .postgresql/postgresql.key must be a regular file
	  owned by the user, and allow no access by 'group' or 'other'.

   At the current time encrypted private keys are not supported.
   There should also be a way to support multiple client certs/keys.

*) the front-end performs minimal validation of the back-end cert.
   Self-signed certs are permitted, but the common name *must*
   match the hostname used by the front-end.  (The cert itself
   should always use a fully qualified domain name (FDQN) in its
   common name field.)

   This means that

	  psql -h eris db

   will fail, but

	  psql -h eris.example.com db

   will succeed.  At the current time this must be an exact match;
   future patches may support any FQDN that resolves to the address
   returned by getpeername(2).

   Another common "problem" is expiring certs.  For now, it may be
   a good idea to use a very-long-lived self-signed cert.

   As a compile-time option, the front-end can specify a file
   containing valid root certificates, but it is not yet required.

*) the back-end performs minimal validation of the client cert.
   It allows self-signed certs.  It checks for expiration.  It
   supports a compile-time option specifying a file containing
   valid root certificates.

*) both front- and back-ends default to TLSv1, not SSLv3/SSLv2.

*) both front- and back-ends support DSA keys.  DSA keys are
   moderately more expensive on startup, but many people consider
   them preferable than RSA keys.  (E.g., SSH2 prefers DSA keys.)

*) if /dev/urandom exists, both client and server will read 16k
   of randomization data from it.

*) the server can read empheral DH parameters from the files

     $DataDir/dh512.pem
     $DataDir/dh1024.pem
     $DataDir/dh2048.pem
     $DataDir/dh4096.pem

   if none are provided, the server will default to hardcoded
   parameter files provided by the OpenSSL project.

Remaining tasks:

*) the select() clauses need to be revisited - the SSL abstraction
   layer may need to absorb more of the current code to avoid rare
   deadlock conditions.  This also touches on a true solution to
   the pg_eof() problem.

*) the SIGPIPE signal handler may need to be revisited.

*) support encrypted private keys.

*) sessions are not yet fully supported.  (SSL sessions can span
   multiple "connections," and allow the client and server to avoid
   costly renegotiations.)

*) makecert - a script that creates back-end certs.

*) pgkeygen - a tool that creates front-end certs.

*) the whole protocol issue, SASL, etc.

 *) certs are fully validated - valid root certs must be available.
    This is a hassle, but it means that you *can* trust the identity
    of the server.

 *) the client library can handle hardcoded root certificates, to
    avoid the need to copy these files.

 *) host name of server cert must resolve to IP address, or be a
    recognized alias.  This is more liberal than the previous
    iteration.

 *) the number of bytes transferred is tracked, and the session
    key is periodically renegotiated.

 *) basic cert generation scripts (mkcert.sh, pgkeygen.sh).  The
    configuration files have reasonable defaults for each type
    of use.

Bear Giles
2002-06-14 03:56:47 +00:00
..
.cvsignore Add cvs. 1999-12-18 00:34:48 +00:00
command.c Remove traces of NAMEDATALEN and INDEX_MAX_KEYS from psql. Build buffers 2002-04-24 05:24:00 +00:00
command.h Reset parenthesis level counter upon \r. 2002-03-27 19:16:13 +00:00
common.c Change made to elog: 2002-03-06 06:10:59 +00:00
common.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
copy.c Remove reference to BLCKSZ. 2002-04-24 21:00:10 +00:00
copy.h Another pgindent run. Fixes enum indenting, and improves #endif 2001-10-28 06:26:15 +00:00
create_help.pl Makefile cleanup for bin and pl subtrees. They should now support 2000-06-27 00:32:06 +00:00
cs.po Czech translation updates from Karel Zak 2001-12-21 22:30:49 +00:00
de.po updates 2001-11-02 19:16:47 +00:00
describe.c Make operators have their own comments separate from those of the 2002-05-13 17:45:30 +00:00
describe.h Add psql \dD listing of domains, from Jonathan Eisler. 2002-03-19 02:32:21 +00:00
fr.po update 2001-12-13 22:04:40 +00:00
help.c psql \? cleanups by Ian Barwick 2002-03-19 03:01:01 +00:00
help.h Another pgindent run. Fixes enum indenting, and improves #endif 2001-10-28 06:26:15 +00:00
input.c Readline and Zlib now required by default. Add options --without-readline 2002-04-10 22:47:09 +00:00
input.h Readline and Zlib now required by default. Add options --without-readline 2002-04-10 22:47:09 +00:00
large_obj.c Change made to elog: 2002-03-06 06:10:59 +00:00
large_obj.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
mainloop.c Reset parenthesis level counter upon \r. 2002-03-27 19:16:13 +00:00
mainloop.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
Makefile Commit Patrice's patches except: 2001-10-15 01:25:10 +00:00
mbprint.c Another pgindent run. Fixes enum indenting, and improves #endif 2001-10-28 06:26:15 +00:00
mbprint.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
nls.mk NLS updates, most notably fixed zh_TW translations 2001-11-29 18:59:28 +00:00
print.c Don't dump core on empty table. 2002-04-24 15:56:38 +00:00
print.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
prompt.c pgindent run on all C files. Java run to follow. initdb/regression 2001-10-25 05:50:21 +00:00
prompt.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
ru.po Update from Serguei Mokhov 2001-09-16 23:06:33 +00:00
settings.h Add \timing patch to psql. Times all queries. 2002-03-05 00:01:03 +00:00
startup.c Attached are a revised set of SSL patches. Many of these patches 2002-06-14 03:56:47 +00:00
stringutils.c Massive commits for SunOS4 port. 2001-02-27 08:13:31 +00:00
stringutils.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
sv.po update 2001-12-10 13:03:12 +00:00
tab-complete.c Restructure representation of aggregate functions so that they have pg_proc 2002-04-11 20:00:18 +00:00
tab-complete.h Another pgindent run. Fixes enum indenting, and improves #endif 2001-10-28 06:26:15 +00:00
variables.c Restructure the key include files per recent pghackers discussion: there 2001-02-10 02:31:31 +00:00
variables.h New pgindent run with fixes suggested by Tom. Patch manually reviewed, 2001-11-05 17:46:40 +00:00
win32.mak Remove compile errors of psql.exe and libpq.dll under 2001-11-22 10:18:52 +00:00
zh_CN.po Chinese for psql and pg_dump. 2001-11-26 17:56:32 +00:00
zh_TW.po Update to get around backslash problems 2001-12-03 19:56:43 +00:00