File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1851,6 +1851,7 @@ QSslSocketPrivate::QSslSocketPrivate()
1851
1851
, mode(QSslSocket::UnencryptedMode)
1852
1852
, autoStartHandshake(false )
1853
1853
, connectionEncrypted(false )
1854
+ , shutdown(false )
1854
1855
, ignoreAllSslErrors(false )
1855
1856
, readyReadEmittedPointer(0 )
1856
1857
, allowRootCertOnDemandLoading(true )
@@ -1875,6 +1876,7 @@ void QSslSocketPrivate::init()
1875
1876
autoStartHandshake = false ;
1876
1877
connectionEncrypted = false ;
1877
1878
ignoreAllSslErrors = false ;
1879
+ shutdown = false ;
1878
1880
1879
1881
// we don't want to clear the ignoreErrorsList, so
1880
1882
// that it is possible setting it before connecting
Original file line number Diff line number Diff line change @@ -1163,8 +1163,11 @@ void QSslSocketBackendPrivate::transmit()
1163
1163
#ifdef QSSLSOCKET_DEBUG
1164
1164
qDebug () << " QSslSocketBackendPrivate::transmit: remote disconnect" ;
1165
1165
#endif
1166
- plainSocket->disconnectFromHost ();
1167
- break ;
1166
+ shutdown = true ; // the other side shut down, make sure we do not send shutdown ourselves
1167
+ q->setErrorString (QSslSocket::tr (" The TLS/SSL connection has been closed" ));
1168
+ q->setSocketError (QAbstractSocket::RemoteHostClosedError);
1169
+ emit q->error (QAbstractSocket::RemoteHostClosedError);
1170
+ return ;
1168
1171
case SSL_ERROR_SYSCALL: // some IO error
1169
1172
case SSL_ERROR_SSL: // error in the SSL library
1170
1173
// we do not know exactly what the error is, nor whether we can recover from it,
@@ -1447,8 +1450,11 @@ bool QSslSocketBackendPrivate::startHandshake()
1447
1450
void QSslSocketBackendPrivate::disconnectFromHost ()
1448
1451
{
1449
1452
if (ssl) {
1450
- q_SSL_shutdown (ssl);
1451
- transmit ();
1453
+ if (!shutdown) {
1454
+ q_SSL_shutdown (ssl);
1455
+ shutdown = true ;
1456
+ transmit ();
1457
+ }
1452
1458
}
1453
1459
plainSocket->disconnectFromHost ();
1454
1460
}
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ class QSslSocketPrivate : public QTcpSocketPrivate
108
108
QSslSocket::SslMode mode;
109
109
bool autoStartHandshake;
110
110
bool connectionEncrypted;
111
+ bool shutdown;
111
112
bool ignoreAllSslErrors;
112
113
QList<QSslError> ignoreErrorsList;
113
114
bool * readyReadEmittedPointer;
Original file line number Diff line number Diff line change @@ -1996,7 +1996,8 @@ void tst_QSslSocket::writeBigChunk()
1996
1996
QFAIL (" Error while writing! Check if the OpenSSL BIO size is limited?!" );
1997
1997
}
1998
1998
// also check the error string. If another error (than UnknownError) occurred, it should be different than before
1999
- QVERIFY (errorBefore == errorAfter);
1999
+ QVERIFY2 (errorBefore == errorAfter || socket->error () == QAbstractSocket::RemoteHostClosedError,
2000
+ QByteArray (" unexpected error: " ).append (qPrintable (errorAfter)));
2000
2001
2001
2002
// check that everything has been written to OpenSSL
2002
2003
QVERIFY (socket->bytesToWrite () == 0 );
You can’t perform that action at this time.
0 commit comments