summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2015-07-13 05:40:22 -0700
committerJeremy Lainé <jeremy.laine@m4x.org>2015-07-13 20:15:01 +0000
commit3ebbd5db7b96b8759119f7811bb40f5e1de45d0f (patch)
tree1e7d752585baa206e36c0e59b6e362d1a1c3ad2d
parentc9dd554ea600f5a3c23053a507c2ef1e4c124f4e (diff)
ssl: fix SecureTransport handling of remote host disconnect
Currently when the remote server disconnects gracefully (for example upon returning an HTTP request with Connection: close) the call to SSLRead will return errSSLCloseGraceful which is incorrectly reported as QAbstractSocket::SslInternalError. This patch aligns the behavior with that of the OpenSSL backend and instead reports QAbstractSocket::RemoteHostClosedError. Change-Id: I8c6679280ac0c6fbd71d5f0d29b25f692eca5b24 Task-number: QTBUG-47154 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
-rw-r--r--src/network/ssl/qsslsocket_mac.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp
index 497cbf4c9b..10a9c0b7e9 100644
--- a/src/network/ssl/qsslsocket_mac.cpp
+++ b/src/network/ssl/qsslsocket_mac.cpp
@@ -387,7 +387,12 @@ void QSslSocketBackendPrivate::transmit()
size_t readBytes = 0;
data.resize(4096);
const OSStatus err = SSLRead(context, data.data(), data.size(), &readBytes);
- if (err != noErr && err != errSSLWouldBlock) {
+ if (err == errSSLClosedGraceful) {
+ shutdown = true; // the other side shut down, make sure we do not send shutdown ourselves
+ setError(QSslSocket::tr("The TLS/SSL connection has been closed"),
+ QAbstractSocket::RemoteHostClosedError);
+ break;
+ } else if (err != noErr && err != errSSLWouldBlock) {
qWarning() << Q_FUNC_INFO << "SSLRead failed with:" << int(err);
setError("SSL read failed", QAbstractSocket::SslInternalError);
break;