From 988c90194b46bdb232ae958857ab846de4717d42 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 22 Feb 2020 20:53:48 +0100 Subject: [PATCH] ssl_recv_data(): Properly handle MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY Previously ssl_recv_data() would pass it to the caller which would treat it as an error. Sponsored by: Robert Klemme --- ssl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ssl.c b/ssl.c index 56360fc8..7faee3a1 100644 --- a/ssl.c +++ b/ssl.c @@ -289,6 +289,12 @@ extern int ssl_recv_data(mbedtls_ssl_context *ssl, unsigned char *buf, size_t ma { char err_buf[ERROR_BUF_SIZE]; + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) + { + log_error(LOG_LEVEL_CONNECT, + "The peer notified us that the connection is going to be closed"); + return 0; + } mbedtls_strerror(ret, err_buf, sizeof(err_buf)); log_error(LOG_LEVEL_ERROR, "Receiving data over TLS/SSL failed: %s", err_buf); -- 2.39.2