ssl_recv_data(): Properly handle MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
authorFabian Keil <fk@fabiankeil.de>
Sat, 22 Feb 2020 19:53:48 +0000 (20:53 +0100)
committerFabian Keil <fk@fabiankeil.de>
Sun, 23 Feb 2020 12:04:15 +0000 (13:04 +0100)
Previously ssl_recv_data() would pass it to the caller
which would treat it as an error.

Sponsored by: Robert Klemme

ssl.c

diff --git a/ssl.c b/ssl.c
index 56360fc..7faee3a 100644 (file)
--- 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);