diff --git a/src/session.cpp b/src/session.cpp --- a/src/session.cpp +++ b/src/session.cpp @@ -80,6 +80,19 @@ } } +void SessionPrivate::startHandshake() +{ + QByteArray cmd; + if (!m_ehloRejected) { + cmd = "EHLO "; + } else { + cmd = "HELO "; + } + setState(Session::Handshake); + const auto hostname = m_customHostname.isEmpty() ? m_thread->hostName() : m_customHostname; + sendData(cmd + QUrl::toAce(hostname)); +} + Session::Session(const QString &hostName, quint16 port, QObject *parent) @@ -277,15 +290,7 @@ if (m_state == Session::Ready) { if (r.isCode(22) || m_ehloRejected) { - QByteArray cmd; - if (!m_ehloRejected) { - cmd = "EHLO "; - } else { - cmd = "HELO "; - } - setState(Session::Handshake); - const auto hostname = m_customHostname.isEmpty() ? m_thread->hostName() : m_customHostname; - sendData(cmd + QUrl::toAce(hostname)); + startHandshake(); return; } } @@ -346,7 +351,11 @@ void SessionPrivate::encryptionNegotiationResult(bool encrypted, KTcpSocket::SslVersion version) { - Q_UNUSED(encrypted); + if (encrypted) { + // Get the updated auth methods + startHandshake(); + } + m_sslVersion = version; } diff --git a/src/session_p.h b/src/session_p.h --- a/src/session_p.h +++ b/src/session_p.h @@ -73,6 +73,7 @@ private: + void startHandshake(); void startNext(); void startSocketTimer(); void stopSocketTimer(); diff --git a/src/sessionthread.cpp b/src/sessionthread.cpp --- a/src/sessionthread.cpp +++ b/src/sessionthread.cpp @@ -223,7 +223,6 @@ } else { qCDebug(KSMTP_LOG) << "TLS negotiation done."; - QMetaObject::invokeMethod(this, "sendData", Qt::QueuedConnection, Q_ARG(QByteArray, "EHLO " + QUrl::toAce(hostName()))); Q_EMIT encryptionNegotiationResult(true, m_socket->negotiatedSslVersion()); } }