summaryrefslogtreecommitdiff
path: root/src/backend/libpq/be-secure.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2003-01-08 23:18:25 +0000
committerBruce Momjian <bruce@momjian.us>2003-01-08 23:18:25 +0000
commitb56af49849f3f4f1aa95f31a74dc7ff3a14b575a (patch)
tree8802f00224812b8a8ddd5d567298d1d944b640b0 /src/backend/libpq/be-secure.c
parent6ccb5aebaddd9e7aefaa7d1e7baa3264148be3c5 (diff)
The second was that renegotiation was just plain broken. I can't
believe I didn't notice this before -- once 64k was sent to/from the server the client would crash. Basicly, in 7.3 the server SSL code set the initial state to "about to renegotiate" without actually starting the renegotiation. In addition, the server and client didn't properly handle the SSL_ERROR_WANT_(READ|WRITE) error. This is fixed in the second patch. Nathan Mueller
Diffstat (limited to 'src/backend/libpq/be-secure.c')
-rw-r--r--src/backend/libpq/be-secure.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index c73eab42cd3..fc0c982b481 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.22 2003/01/08 22:56:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.23 2003/01/08 23:18:25 momjian Exp $
*
* Since the server static private key ($DataDir/server.key)
* will normally be stored unencrypted so that the database
@@ -273,12 +273,6 @@ secure_read(Port *port, void *ptr, size_t len)
#ifdef USE_SSL
if (port->ssl)
{
- if (port->count > RENEGOTIATION_LIMIT)
- {
- SSL_renegotiate(port->ssl);
- port->count = 0;
- }
-
n = SSL_read(port->ssl, ptr, len);
switch (SSL_get_error(port->ssl, n))
{
@@ -286,6 +280,7 @@ secure_read(Port *port, void *ptr, size_t len)
port->count += n;
break;
case SSL_ERROR_WANT_READ:
+ n = secure_read(port, ptr, len);
break;
case SSL_ERROR_SYSCALL:
if (n == -1)
@@ -325,7 +320,15 @@ secure_write(Port *port, const void *ptr, size_t len)
{
if (port->count > RENEGOTIATION_LIMIT)
{
- SSL_renegotiate(port->ssl);
+ SSL_set_session_id_context(port->ssl, (void *)&SSL_context, sizeof(SSL_context));
+
+ if (SSL_renegotiate(port->ssl) <= 0)
+ elog(COMMERROR, "SSL renegotiation failure");
+ if (SSL_do_handshake(port->ssl) <= 0)
+ elog(COMMERROR, "SSL renegotiation failure");
+ port->ssl->state=SSL_ST_ACCEPT;
+ if (SSL_do_handshake(port->ssl) <= 0)
+ elog(COMMERROR, "SSL renegotiation failure");
port->count = 0;
}
@@ -336,6 +339,7 @@ secure_write(Port *port, const void *ptr, size_t len)
port->count += n;
break;
case SSL_ERROR_WANT_WRITE:
+ n = secure_read(port, ptr, len);
break;
case SSL_ERROR_SYSCALL:
if (n == -1)