QSslSocket: Set isEncrypted to false on disconnect

Since we're no longer connected, much less encrypted.
Was done in schannel backend, but not in ST or OpenSSL

Pick-to: 6.2
Change-Id: Ia49387be0088f899a0c89091f7e468dba1c0eee6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Mårten Nordheim 2021-06-24 13:59:09 +02:00
parent 1587d75b5e
commit 664a6621fb
3 changed files with 3 additions and 0 deletions

View File

@ -1127,6 +1127,7 @@ void TlsCryptographOpenSSL::disconnected()
Q_ASSERT(d);
auto *plainSocket = d->plainTcpSocket();
Q_ASSERT(plainSocket);
d->setEncrypted(false);
if (plainSocket->bytesAvailable() <= 0) {
destroySslContext();

View File

@ -398,6 +398,7 @@ void TlsCryptographSecureTransport::continueHandshake()
void TlsCryptographSecureTransport::disconnected()
{
Q_ASSERT(d && d->plainTcpSocket());
d->setEncrypted(false);
if (d->plainTcpSocket()->bytesAvailable() <= 0)
destroySslContext();
// If there is still buffered data in the plain socket, don't destroy the ssl context yet.

View File

@ -1092,6 +1092,7 @@ void tst_QSslSocket::connectToHostEncrypted()
socket->disconnectFromHost();
QVERIFY(socket->waitForDisconnected());
QVERIFY(!socket->isEncrypted());
QCOMPARE(socket->mode(), QSslSocket::SslClientMode);