mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: ssl: improve socket behaviour upon handshake abort.
While checking haproxy's SSL stack with www.ssllabs.com, it appeared that immediately closing upon a failed handshake caused a TCP reset to be emitted. This is because OpenSSL does not consume pending data in the socket buffers. One side effect is that if the reset packet is lost, the client might not get it. So now when a handshake fails, we try to clean the socket buffers before closing, resulting in a clean FIN instead of an RST.
This commit is contained in:
parent
2e845be249
commit
566dc5545b
@ -856,6 +856,12 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Fail on all other handshake errors */
|
/* Fail on all other handshake errors */
|
||||||
|
/* Note: OpenSSL may leave unread bytes in the socket's
|
||||||
|
* buffer, causing an RST to be emitted upon close() on
|
||||||
|
* TCP sockets. We first try to drain possibly pending
|
||||||
|
* data to avoid this as much as possible.
|
||||||
|
*/
|
||||||
|
ret = recv(conn->t.sock.fd, trash, trashlen, MSG_NOSIGNAL|MSG_DONTWAIT);
|
||||||
goto out_error;
|
goto out_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user