Skip to content

openssl: Clear error queue after an incomplete SSL_shutdown #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lib-ssl-iostream/iostream-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ static void openssl_iostream_unref(struct ssl_iostream *ssl_io)

static void openssl_iostream_destroy(struct ssl_iostream *ssl_io)
{
(void)SSL_shutdown(ssl_io->ssl);
if (SSL_shutdown(ssl_io->ssl) != 1) {
/* if bidirectional shutdown fails we need to clear
the error queue */
openssl_iostream_clear_errors();
}
(void)openssl_iostream_more(ssl_io);
(void)o_stream_flush(ssl_io->plain_output);
/* close the plain i/o streams, because their fd may be closed soon,
Expand Down
6 changes: 5 additions & 1 deletion src/login-common/ssl-proxy-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,11 @@ void ssl_proxy_destroy(struct ssl_proxy *proxy)
if (proxy->io_plain_write != NULL)
io_remove(&proxy->io_plain_write);

(void)SSL_shutdown(proxy->ssl);
if (SSL_shutdown(proxy->ssl) != 1) {
/* if bidirectional shutdown fails we need to clear
the error queue. */
openssl_iostream_clear_errors();
}

net_disconnect(proxy->fd_ssl);
net_disconnect(proxy->fd_plain);
Expand Down