]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
rustls: Handle close_notify.
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>
Thu, 18 Mar 2021 04:27:12 +0000 (21:27 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 20 Mar 2021 23:16:27 +0000 (00:16 +0100)
If we get a close_notify, treat that as EOF. If we get an EOF from the
TCP stream, treat that as an error (because we should have ended the
connection earlier, when we got a close_notify).

Closes #6763

lib/vtls/rustls.c

index 3b7bc3afb7221e85b26ce65cbb3555752709d76c..e4f589de57ae2786078e34fbb22cafd99cdf430a 100644 (file)
@@ -112,7 +112,7 @@ cr_recv(struct Curl_easy *data, int sockindex,
 
   tls_bytes_read = sread(sockfd, backend->tlsbuf, TLSBUF_SIZE);
   if(tls_bytes_read == 0) {
-    failf(data, "EOF in sread");
+    failf(data, "connection closed without TLS close_notify alert");
     *err = CURLE_READ_ERROR;
     return -1;
   }
@@ -163,7 +163,11 @@ cr_recv(struct Curl_easy *data, int sockindex,
       (uint8_t *)plainbuf + plain_bytes_copied,
       plainlen - plain_bytes_copied,
       &n);
-    if(rresult != RUSTLS_RESULT_OK) {
+    if(rresult == RUSTLS_RESULT_ALERT_CLOSE_NOTIFY) {
+      *err = CURLE_OK;
+      return 0;
+    }
+    else if(rresult != RUSTLS_RESULT_OK) {
       failf(data, "error in rustls_client_session_read");
       *err = CURLE_READ_ERROR;
       return -1;