diff --git a/core/backends/lan/landevicelink.cpp b/core/backends/lan/landevicelink.cpp index 1d23cd8db..bdc6e4226 100644 --- a/core/backends/lan/landevicelink.cpp +++ b/core/backends/lan/landevicelink.cpp @@ -53,17 +53,8 @@ void LanDeviceLink::reset(QSslSocket* socket, DeviceLink::ConnectionStarted conn setConnectionSource(connectionSource); - if (m_certificate.isNull()) { - - QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), "certificate"); - m_certificate = QSslCertificate(certString.toLatin1()); - - QString keyString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), "publicKey"); - m_publicKey = QCA::PublicKey::fromPEM(keyString.toLatin1()); - - DeviceLink::setPairStatus(m_certificate.isNull()? PairStatus::NotPaired : PairStatus::Paired); - } - + QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), "certificate"); + DeviceLink::setPairStatus(certString.isEmpty()? PairStatus::NotPaired : PairStatus::Paired); } QString LanDeviceLink::name() @@ -145,19 +136,10 @@ void LanDeviceLink::setPairStatus(PairStatus status) { if (status == Paired) { Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId())); - Q_ASSERT(!m_certificate.isNull()); - Q_ASSERT(!m_publicKey.isNull()); - KdeConnectConfig::instance()->setDeviceProperty(deviceId(), "certificate", m_certificate.toPem()); - KdeConnectConfig::instance()->setDeviceProperty(deviceId(), "publicKey", m_publicKey.toPEM()); + Q_ASSERT(!mSocketLineReader->peerCertificate().isNull()); + KdeConnectConfig::instance()->setDeviceProperty(deviceId(), "certificate", mSocketLineReader->peerCertificate().toPem()); } DeviceLink::setPairStatus(status); } -void LanDeviceLink::setCertificate(QSslCertificate certificate, QCA::PublicKey publicKey) -{ - Q_ASSERT(!m_certificate.isNull()); - Q_ASSERT(!m_publicKey.isNull()); - m_certificate = certificate; - m_publicKey = publicKey; -} diff --git a/core/backends/lan/landevicelink.h b/core/backends/lan/landevicelink.h index 07b395987..28978c03b 100644 --- a/core/backends/lan/landevicelink.h +++ b/core/backends/lan/landevicelink.h @@ -42,15 +42,11 @@ public: virtual QString name() Q_DECL_OVERRIDE; bool sendPackage(NetworkPackage& np) override; - bool sendPackageEncrypted(NetworkPackage& np) override; UploadJob* sendPayload(NetworkPackage& np); virtual void userRequestsPair() override; virtual void userRequestsUnpair() override; - void setCertificate(QSslCertificate certificate, QCA::PublicKey publicKey); - QSslCertificate certificate() { return m_certificate; } - virtual void setPairStatus(PairStatus status) override; private Q_SLOTS: @@ -58,9 +54,6 @@ private Q_SLOTS: private: SocketLineReader* mSocketLineReader; - - QCA::PublicKey m_publicKey; - QSslCertificate m_certificate; }; #endif diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index e16ce01e8..35a1d44a3 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -264,8 +264,6 @@ void LanLinkProvider::encrypted() const QString& deviceId = receivedPackage->get("deviceId"); //qCDebug(KDECONNECT_CORE) << "Connected" << socket->isWritable(); - receivedPackage->set("certificate", socket->peerCertificate().toPem()); - addLink(deviceId, socket, receivedPackage, DeviceLink::Remotely); // Copied from connected slot, now delete received package diff --git a/core/backends/lan/lanpairinghandler.cpp b/core/backends/lan/lanpairinghandler.cpp index 8ca0e2aa3..2a5882904 100644 --- a/core/backends/lan/lanpairinghandler.cpp +++ b/core/backends/lan/lanpairinghandler.cpp @@ -59,19 +59,6 @@ void LanPairingHandler::packageReceived(const NetworkPackage& np) if (wantsPair) { - QString keyString = np.get("publicKey"); - QString certificateString = np.get("certificate"); - QCA::PublicKey publicKey = QCA::PublicKey::fromPEM(keyString); - QSslCertificate certificate(keyString.toLatin1()); - if (certificate.isNull()) { - if (isPairRequested()) { - setInternalPairStatus(NotPaired); - } - Q_EMIT pairingError(i18n("Received incorrect certificate")); - return; - } - qobject_cast(deviceLink())->setCertificate(certificate, publicKey); - if (isPairRequested()) { //We started pairing qCDebug(KDECONNECT_CORE) << "Pair answer"; diff --git a/core/backends/lan/socketlinereader.h b/core/backends/lan/socketlinereader.h index 03f8a6225..62daef9c6 100644 --- a/core/backends/lan/socketlinereader.h +++ b/core/backends/lan/socketlinereader.h @@ -42,6 +42,7 @@ public: QByteArray readLine() { return mPackages.dequeue(); } qint64 write(const QByteArray& data) { return mSocket->write(data); } QHostAddress peerAddress() const { return mSocket->peerAddress(); } + QSslCertificate peerCertificate() const { return mSocket->peerCertificate(); } qint64 bytesAvailable() const { return mPackages.size(); } Q_SIGNALS: