]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add configuration parameter ssl_renegotiation_limit to control
authorMagnus Hagander <magnus@hagander.net>
Thu, 25 Feb 2010 13:26:23 +0000 (13:26 +0000)
committerMagnus Hagander <magnus@hagander.net>
Thu, 25 Feb 2010 13:26:23 +0000 (13:26 +0000)
how often we do SSL session key renegotiation. Can be set to
0 to disable renegotiation completely, which is required if
a broken SSL library is used (broken patches to CVE-2009-3555
a known cause) or when using a client library that can't do
renegotiation.

doc/src/sgml/config.sgml
src/backend/libpq/be-secure.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample

index 50cb5edb0814e75d85e6edcaa887cd357fd1b793..e89aeb5aa580e949f2972a211f6cdc340d5a8fc5 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.164.2.6 2008/12/08 15:11:42 mha Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.164.2.7 2010/02/25 13:26:22 mha Exp $ -->
 
 <chapter Id="runtime-config">
   <title>Server Configuration</title>
@@ -569,6 +569,32 @@ SET ENABLE_SEQSCAN TO OFF;
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-ssl-renegotiation-limit" xreflabel="ssl_renegotiation_limit">
+      <term><varname>ssl_renegotiation_limit</varname> (<type>int</type>)</term>
+      <indexterm>
+       <primary><varname>ssl_renegotiation_limit</> configuration parameter</primary>
+      </indexterm>
+      <listitem>
+       <para>
+        Specifies how much data can flow over an <acronym>SSL</> encrypted connection
+        before renegotiation of the session will take place. Renegotiation of the
+        session decreases the chance of doing cryptanalysis when large amounts of data
+        are sent, but it also carries a large performance penalty. The sum of
+        sent and received traffic is used to check the limit. If the parameter is
+        set to 0, renegotiation is disabled. The default is <literal>512MB</>.
+       </para>
+       <note>
+        <para>
+         SSL libraries from before November 2009 are insecure when using SSL
+         renegotiation, due to a vulnerability in the SSL protocol. As a stop-gap fix
+         for this vulnerability, some vendors also shipped SSL libraries incapable
+         of doing renegotiation. If any of these libraries are in use on the client
+         or server, SSL renegotiation should be disabled.
+        </para>
+       </note>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-ssl-ciphers" xreflabel="ssl_ciphers">
       <term><varname>ssl_ciphers</varname> (<type>string</type>)</term>
       <indexterm>
index b3a4416f244db13027877b0b16a86c35cc56f609..f595e8f42404181500b73ef9d7f27cb2c60d931f 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.83.2.3 2009/12/30 03:46:01 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.83.2.4 2010/02/25 13:26:22 mha Exp $
  *
  *       Since the server static private key ($DataDir/server.key)
  *       will normally be stored unencrypted so that the database
@@ -120,13 +120,14 @@ static void close_SSL(Port *);
 static const char *SSLerrmessage(void);
 #endif
 
-#ifdef USE_SSL
 /*
  *     How much data can be sent across a secure connection
  *     (total in both directions) before we require renegotiation.
+ *     Set to 0 to disable renegotiation completely.
  */
-#define RENEGOTIATION_LIMIT (512 * 1024 * 1024)
+int ssl_renegotiation_limit;
 
+#ifdef USE_SSL
 static SSL_CTX *SSL_context = NULL;
 
 /* GUC variable controlling SSL cipher list */
@@ -338,7 +339,7 @@ secure_write(Port *port, void *ptr, size_t len)
        {
                int                     err;
 
-               if (port->count > RENEGOTIATION_LIMIT)
+               if (ssl_renegotiation_limit && port->count > ssl_renegotiation_limit * 1024L)
                {
                        SSL_set_session_id_context(port->ssl, (void *) &SSL_context,
                                                                           sizeof(SSL_context));
index 2c86df6b564c41b555e6d4a0a8fe8f6598fbd738..ba6e781c1c0d3dc7c54b06bacaea1b5f10a39805 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut <peter_e@gmx.net>.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432.2.6 2010/01/24 21:49:39 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432.2.7 2010/02/25 13:26:22 mha Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -112,6 +112,7 @@ extern char *default_tablespace;
 extern char *temp_tablespaces;
 extern bool synchronize_seqscans;
 extern bool fullPageWrites;
+extern int     ssl_renegotiation_limit;
 
 #ifdef TRACE_SORT
 extern bool trace_sort;
@@ -1720,6 +1721,16 @@ static struct config_int ConfigureNamesInt[] =
                0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval
        },
 
+       {
+               {"ssl_renegotiation_limit", PGC_USERSET, CONN_AUTH_SECURITY,
+                       gettext_noop("Set the amount of traffic to send and receive before renegotiating the encryption keys."),
+                       NULL,
+                       GUC_UNIT_KB,
+               },
+               &ssl_renegotiation_limit,
+               512 * 1024, 0, MAX_KILOBYTES, NULL, NULL
+       },
+
        {
                {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER,
                        gettext_noop("Maximum number of TCP keepalive retransmits."),
index 258a7d1a4f519942d23b3eef13ea54be9fbaf5d2..4487b21c93de1f684c8dcfdf93a40ee303e5ef6b 100644 (file)
@@ -76,6 +76,7 @@
 #ssl = off                             # (change requires restart)
 #ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH'     # allowed SSL ciphers
                                        # (change requires restart)
+#ssl_renegotiation_limit = 512MB       # amount of data between renegotiations
 #password_encryption = on
 #db_user_namespace = off