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>
This commit is contained in:
Jeremy Lainé 2015-07-13 05:40:22 -07:00
parent c9dd554ea6
commit 3ebbd5db7b

View File

@ -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;