Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 272923a

Browse files
committed
Simplify the way OpenSSL renegotiation is initiated in server.
At least in all modern versions of OpenSSL, it is enough to call SSL_renegotiate() once, and then forget about it. Subsequent SSL_write() and SSL_read() calls will finish the handshake. The SSL_set_session_id_context() call is unnecessary too. We only have one SSL context, and the SSL session was created with that to begin with.
1 parent dc01efa commit 272923a

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

src/backend/libpq/be-secure-openssl.c

-23
Original file line numberDiff line numberDiff line change
@@ -624,33 +624,10 @@ be_tls_write(Port *port, void *ptr, size_t len)
624624
*/
625625
SSL_clear_num_renegotiations(port->ssl);
626626

627-
SSL_set_session_id_context(port->ssl, (void *) &SSL_context,
628-
sizeof(SSL_context));
629627
if (SSL_renegotiate(port->ssl) <= 0)
630628
ereport(COMMERROR,
631629
(errcode(ERRCODE_PROTOCOL_VIOLATION),
632630
errmsg("SSL failure during renegotiation start")));
633-
else
634-
{
635-
int retries;
636-
637-
/*
638-
* A handshake can fail, so be prepared to retry it, but only
639-
* a few times.
640-
*/
641-
for (retries = 0;; retries++)
642-
{
643-
if (SSL_do_handshake(port->ssl) > 0)
644-
break; /* done */
645-
ereport(COMMERROR,
646-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
647-
errmsg("SSL handshake failure on renegotiation, retrying")));
648-
if (retries >= 20)
649-
ereport(FATAL,
650-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
651-
errmsg("could not complete SSL handshake on renegotiation, too many failures")));
652-
}
653-
}
654631
}
655632

656633
wloop:

0 commit comments

Comments
 (0)