From a10467b58ab92352217c7ab42eafd320bb671565 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 3 Mar 2017 15:46:23 +1100 Subject: [PATCH] extmod/modussl_mbedtls: When reading and peer wants to close, return 0. If this particular code is returned then there's no more data, it's not really an error. --- extmod/modussl_mbedtls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index f4b551cb9b..ef3f319fe1 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -192,6 +192,10 @@ STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in); int ret = mbedtls_ssl_read(&o->ssl, buf, size); + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // end of stream + return 0; + } if (ret >= 0) { return ret; }