X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientauthhandler.cpp;h=260128b7b7ef16c5eeb0a70665a63ebf36048bd4;hp=44743ae8210e5e9c8a12f7d894354f00bf064008;hb=efe4239f96f0cf10b1c94e87f8fdd21f3bdbe10e;hpb=1a5c1814a0c52f6f35e65c7033b2f896bf1188e3 diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 44743ae8..260128b7 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -159,8 +159,7 @@ void ClientAuthHandler::onSocketConnected() stream.setVersion(QDataStream::Qt_4_2); quint32 magic = Protocol::magic; - if (_account.useSsl()) - magic |= Protocol::Encryption; + magic |= Protocol::Encryption; magic |= Protocol::Compression; stream << magic; @@ -253,7 +252,7 @@ void ClientAuthHandler::setPeer(RemotePeer* peer) connect(_peer, &RemotePeer::transferProgress, this, &ClientAuthHandler::transferProgress); // The legacy protocol enables SSL later, after registration - if (!_account.useSsl() || _legacy) + if (_legacy) startRegistration(); // otherwise, do it now else @@ -264,11 +263,7 @@ void ClientAuthHandler::startRegistration() { emit statusMessage(tr("Synchronizing to core...")); - // useSsl will be ignored by non-legacy peers - bool useSsl = false; - useSsl = _account.useSsl(); - - _peer->dispatch(Protocol::RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate, useSsl)); + _peer->dispatch(Protocol::RegisterClient(Quassel::Features{}, Quassel::buildInfo().fancyVersionString, Quassel::buildInfo().commitDate)); } void ClientAuthHandler::handle(const Protocol::ClientDenied& msg) @@ -286,7 +281,7 @@ void ClientAuthHandler::handle(const Protocol::ClientRegistered& msg) _peer->setFeatures(std::move(msg.features)); // The legacy protocol enables SSL at this point - if (_legacy && _account.useSsl()) + if (_legacy) checkAndEnableSsl(msg.sslSupported); else onConnectionReady(); @@ -380,17 +375,15 @@ void ClientAuthHandler::handle(const Protocol::SessionState& msg) void ClientAuthHandler::checkAndEnableSsl(bool coreSupportsSsl) { CoreAccountSettings s; - if (coreSupportsSsl && _account.useSsl()) { + if (coreSupportsSsl) { // Make sure the warning is shown next time we don't have SSL in the core s.setAccountValue("ShowNoCoreSslWarning", true); - auto* sslSocket = qobject_cast(socket()); - Q_ASSERT(sslSocket); - connect(sslSocket, &QSslSocket::encrypted, this, &ClientAuthHandler::onSslSocketEncrypted); - connect(sslSocket, selectOverload&>(&QSslSocket::sslErrors), this, &ClientAuthHandler::onSslErrors); + connect(socket(), &QSslSocket::encrypted, this, &ClientAuthHandler::onSslSocketEncrypted); + connect(socket(), selectOverload&>(&QSslSocket::sslErrors), this, &ClientAuthHandler::onSslErrors); qDebug() << "Starting encryption..."; - sslSocket->flush(); - sslSocket->startClientEncryption(); + socket()->flush(); + socket()->startClientEncryption(); } else { if (s.accountValue("ShowNoCoreSslWarning", true).toBool()) { @@ -435,9 +428,6 @@ void ClientAuthHandler::onSslSocketEncrypted() void ClientAuthHandler::onSslErrors() { - auto* socket = qobject_cast(sender()); - Q_ASSERT(socket); - CoreAccountSettings s; QByteArray knownDigest = s.accountValue("SslCert").toByteArray(); ClientAuthHandler::DigestVersion knownDigestVersion = static_cast( @@ -446,11 +436,11 @@ void ClientAuthHandler::onSslErrors() QByteArray calculatedDigest; switch (knownDigestVersion) { case ClientAuthHandler::DigestVersion::Md5: - calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Md5); + calculatedDigest = socket()->peerCertificate().digest(QCryptographicHash::Md5); break; case ClientAuthHandler::DigestVersion::Sha2_512: - calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Sha512); + calculatedDigest = socket()->peerCertificate().digest(QCryptographicHash::Sha512); break; default: @@ -460,7 +450,7 @@ void ClientAuthHandler::onSslErrors() if (knownDigest != calculatedDigest) { bool accepted = false; bool permanently = false; - emit handleSslErrors(socket, &accepted, &permanently); + emit handleSslErrors(socket(), &accepted, &permanently); if (!accepted) { requestDisconnect(tr("Unencrypted connection canceled")); @@ -468,7 +458,7 @@ void ClientAuthHandler::onSslErrors() } if (permanently) { - s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); + s.setAccountValue("SslCert", socket()->peerCertificate().digest(QCryptographicHash::Sha512)); s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } else { @@ -477,9 +467,9 @@ void ClientAuthHandler::onSslErrors() } } else if (knownDigestVersion != ClientAuthHandler::DigestVersion::Latest) { - s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); + s.setAccountValue("SslCert", socket()->peerCertificate().digest(QCryptographicHash::Sha512)); s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } - socket->ignoreSslErrors(); + socket()->ignoreSslErrors(); }