diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index bc11e461e..7ddf635c2 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -1,6 +1,6 @@
add_executable(kdeconnect-cli kdeconnect-cli.cpp)
-target_link_libraries(kdeconnect-cli kdeconnectinterfaces Qt5::Network KF5::CoreAddons KF5::I18n)
+target_link_libraries(kdeconnect-cli kdeconnectinterfaces KF5::CoreAddons KF5::I18n)
install(TARGETS kdeconnect-cli ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index d0a95cdff..94c49e453 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -18,10 +18,10 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
-#include
#include
#include
@@ -148,11 +148,24 @@ int main(int argc, char** argv)
<< ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl;
}
} else if(parser.isSet("encryption-info")) {
- QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device, "org.kde.kdeconnect.device", "certificate");
- msg.setArguments(QVariantList() << QSsl::Pem);
- QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
- QSslCertificate certificate = QSslCertificate::fromData(reply.arguments().first().toByteArray()).first();
- QTextStream(stderr) << certificate.toText() << endl;
+ DeviceDbusInterface dev(device);
+ QDBusPendingReply devReply = dev.certificate(1); // QSsl::Der = 1
+ devReply.waitForFinished();
+ if (devReply.value().isEmpty()) {
+ QTextStream(stderr) << i18n("The other device doesn\'t use a recent version of KDE Connect, using the legacy encryption method.") << endl;
+ } else {
+ QByteArray remoteCertificate = QCryptographicHash::hash(devReply.value(), QCryptographicHash::Sha1).toHex();
+ for (int i=2 ; i ifaceReply = iface.certificate(1); // QSsl::Der = 1
+ ifaceReply.waitForFinished();
+ QByteArray myCertificate = QCryptographicHash::hash(ifaceReply.value(), QCryptographicHash::Sha1).toHex();
+ for (int i=2 ; icertificate().toPem();
+ else return KdeConnectConfig::instance()->certificate().toDer();
+}
+
+
void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl)
{
const QString& id = identityPackage.get("deviceId");
diff --git a/core/daemon.h b/core/daemon.h
index db65b49c2..ec4b57d2c 100644
--- a/core/daemon.h
+++ b/core/daemon.h
@@ -62,6 +62,9 @@ public Q_SLOTS:
//Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false) const;
+ //Exposing kdeconnectconfig through daemon, needed to show certificate hash in cli, but this can be extended to name, id, public key etc. if needed
+ Q_SCRIPTABLE QByteArray certificate(int format) const;
+
virtual void requestPairing(Device *d) = 0;
virtual void reportError(const QString &title, const QString &description) = 0;
virtual QNetworkAccessManager* networkAccessManager();
diff --git a/core/device.h b/core/device.h
index 5d738c1c2..4416b1fae 100644
--- a/core/device.h
+++ b/core/device.h
@@ -87,7 +87,7 @@ public:
QString type() const { return type2str(m_deviceType); }
QCA::PublicKey publicKey() const { return m_publicKey; }
QSslCertificate certificate() const { return m_certificate; }
- Q_SCRIPTABLE QByteArray certificate(int format) const { return (format == QSsl::Pem) ? m_certificate.toPem() : m_certificate.toDer() ;} // To expose certificate through dbus
+ Q_SCRIPTABLE QByteArray certificate(int format) const { return (format == QSsl::Pem) ? m_certificate.toPem() : m_certificate.toDer() ;} // To expose certificate through dbus for cli
QString iconName() const;
QString statusIconName() const;
diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp
index 7f0bf3e08..e835a26e3 100644
--- a/core/kdeconnectconfig.cpp
+++ b/core/kdeconnectconfig.cpp
@@ -22,7 +22,6 @@
#include
-#include
#include
#include
#include
@@ -297,3 +296,4 @@ QDir KdeConnectConfig::pluginConfigDir(QString deviceId, QString pluginName)
return QDir(pluginConfigDir);
}
+
diff --git a/core/kdeconnectconfig.h b/core/kdeconnectconfig.h
index 0042efd4b..1292ff99d 100644
--- a/core/kdeconnectconfig.h
+++ b/core/kdeconnectconfig.h
@@ -23,7 +23,7 @@
#include
#include
-#include
+#include
#include "kdeconnectcore_export.h"