From 156ddfc4e86a8fabaad100349f105e300bcf1234 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Wed, 4 Oct 2017 12:38:19 -0700 Subject: [PATCH] Fix EOF handling of TlsStream.ReadAsync (#2094) --- src/Kestrel.Tls/TlsStream.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Kestrel.Tls/TlsStream.cs b/src/Kestrel.Tls/TlsStream.cs index 6cf8c5e8e0..0b1b583167 100644 --- a/src/Kestrel.Tls/TlsStream.cs +++ b/src/Kestrel.Tls/TlsStream.cs @@ -139,6 +139,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tls if (OpenSsl.BIO_ctrl_pending(_inputBio) == 0) { var bytesRead = await _innerStream.ReadAsync(_inputBuffer, 0, _inputBuffer.Length, cancellationToken); + + if (bytesRead == 0) + { + return 0; + } + OpenSsl.BIO_write(_inputBio, _inputBuffer, 0, bytesRead); }