Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.9.6, 5.12.5
-
None
Description
First, about my 2 testing environments:
1st:
Ubuntu 16.04
Qt 5.9.6
libSSL 1.0.2g
2nd:
Ubuntu 20.04
Qt 5.12.5
libSSL 1.1.1g
Tried 2 different types of servers:
1) my own FTPES (vsftpd) with STARTTLS mandatory
2) SMTP: smtp.office365.com / 587 with STARTTLS
In all combinations of tests code always times out when i'm issuing:
socket->startClientEncryption();
socket->waitForEncrypted(5000); //Here time-out.
and even if i try to set super big values, it anyway times out.
Both FTPES and Microsoft (boviously) servers are working alright.
testes them with other software (FileZilla and BlueMail on Android).
I also did a quick test on WIndows 10 with Qt 5.6.9 and libSSL 1.0.2g
And the code also timed-out
Here is what i found, this is a snippet of 'waitForEncrypted' from qsslsocket.cpp:
bool QSslSocket::waitForEncrypted(int msecs) { Q_D(QSslSocket); if (!d->plainSocket || d->connectionEncrypted) return false; if (d->mode == UnencryptedMode && !d->autoStartHandshake) return false; QElapsedTimer stopWatch; stopWatch.start(); if (d->plainSocket->state() != QAbstractSocket::ConnectedState) { // Wait until we've entered connected state. if (!d->plainSocket->waitForConnected(msecs)) return false; } //Also added here check for timet elapsed, to make this 'timeoutable' while (!d->connectionEncrypted && stopWatch.elapsed() < msecs) { // Start the handshake, if this hasn't been started yet. if (d->mode == UnencryptedMode) startClientEncryption(); // Loop, waiting until the connection has been encrypted or an error // occurs. //Time out happens here plainSocket waitForReadyRead always times out!! //if (!d->plainSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) //return false; //This is my attempt to fix this: just repeatedly run 'transmit' //transmit() has a check inside if there is data to read and reads //it when needed. Connection to FTPES and STARTTLS SMTP works fine //with this fix.! d->transmit(); QCoreApplication::processEvents( QEventLoop::AllEvents, 100 ); } return d->connectionEncrypted; }
Please review, and your thoughts about it?
Also as a side note - if i connect to regular TLS server (not STARTTLS)
that i connect to with '->connectToHostEncryted()' - then Qt works as needed
in all my environtments!
Problem arises only with servers that are STARTTLS - based!
Thank you for attention!