From c89404edf3f3b35a4a599d71f407055bda8261b6 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Thu, 13 Nov 2008 09:45:25 +0000 Subject: Fix libpq certificate validation for SSL connections. Add config parameter "sslverify" to control the verification. Default is to do full verification. Clean up some old SSL code that never really worked. --- doc/src/sgml/libpq.sgml | 53 +++++++++++++++++++++++++++++++++++++++++++---- doc/src/sgml/runtime.sgml | 16 +++++++------- 2 files changed, 58 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 6f977f9083e..0b220ab514b 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,4 +1,4 @@ - + <application>libpq</application> - C Library @@ -259,6 +259,33 @@ + + sslverify + + + This option controls how libpq verifies the certificate on the + server when performing an SSL connection. There are + three options: none disables verification completely + (not recommended!); cert enables verification that + the certificate chains to a known CA only; cn will + both verify that the certificate chains to a known CA and that + the cn attribute of the certificate matches the + hostname the connection is being made to (default). + + + + It is always recommended to use the cn value for + this parameter, since this is the only option that prevents + man-in-the-middle attacks. Note that this requires the server + name on the certificate to match exactly with the host name + used for the connection, and therefore does not support connections + to aliased names. It can be used with pure IP address connections + only if the certificate also has just the IP address in the + cn field. + + + + requiressl @@ -5679,6 +5706,22 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) + + + + PGSSLVERIFY + + PGSSLVERIFY controls how libpq verifies the certificate on the + server when performing an SSL connection. There are + three options: none disables verification completely + (not recommended!); cert enables verification that + the certificate chains to a known CA only; cn will + both verify that the certificate chains to a known CA and that + the cn attribute of the certificate matches the + hostname the connection is being made to (default). + + + @@ -6026,9 +6069,11 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) - To verify the server certificate is trustworthy, place certificates of - the certificate authorities (CA) you trust in the - file ~/.postgresql/root.crt in the user's home directory. + When the sslverify parameter is set to cn or + cert, libpq will verify that the server certificate is + trustworthy by checking the certificate chain up to a CA. + For this to work, place the certificate of a trusted CA + in the file ~/.postgresql/root.crt in the user's home directory. (On Microsoft Windows the file is named %APPDATA%\postgresql\root.crt.) libpq will then verify that the server's diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index a46f59cf1fc..b04de288c33 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,4 +1,4 @@ - + Operating System Environment @@ -1418,9 +1418,9 @@ $ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`server.key (key) and server.crt (certificate) files (). The TCP client must connect using - sslmode='require' () and have - a ~/.postgresql/root.crt SSL certificate (). + sslmode='require', specify sslverify='cn' + or sslverify='cert' and have the required certificate + files present (). @@ -1544,8 +1544,8 @@ $ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid` - It is possible for both the client and server to provide SSL keys - or certificates to each other. It takes some extra configuration + It is possible for both the client and server to provide SSL + certificates to each other. It takes some extra configuration on each side, but this provides stronger verification of identity than the mere use of passwords. It prevents a computer from pretending to be the server just long enough to read the password @@ -1757,7 +1757,9 @@ chmod og-rwx server.key A self-signed certificate can be used for testing, but a certificate signed by a certificate authority (CA) (either one of the global CAs or a local one) should be used in production - so the client can verify the server's identity. + so the client can verify the server's identity. If all the clients + are local to the organization, using a local CA is + recommended. -- cgit v1.2.3