Encryption info in cli
This commit is contained in:
parent
e6da860fb7
commit
20e46418ba
6 changed files with 13 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
|
||||
add_executable(kdeconnect-cli kdeconnect-cli.cpp)
|
||||
|
||||
target_link_libraries(kdeconnect-cli kdeconnectinterfaces KF5::CoreAddons KF5::I18n)
|
||||
target_link_libraries(kdeconnect-cli kdeconnectinterfaces Qt5::Network KF5::CoreAddons KF5::I18n)
|
||||
|
||||
install(TARGETS kdeconnect-cli ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
#include <QCoreApplication>
|
||||
#include <QSslCertificate>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <KAboutData>
|
||||
|
@ -56,6 +57,7 @@ int main(int argc, char** argv)
|
|||
parser.addOption(QCommandLineOption("share", i18n("Share a file to a said device"), "path"));
|
||||
parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device")));
|
||||
parser.addOption(QCommandLineOption(QStringList("device") << "d", i18n("Device ID"), "dev"));
|
||||
parser.addOption(QCommandLineOption("encryption-info", i18n("Get encryption info about said device")));
|
||||
about.setupCommandLine(&parser);
|
||||
|
||||
parser.addHelpOption();
|
||||
|
@ -145,6 +147,12 @@ int main(int argc, char** argv)
|
|||
QTextStream(stdout) << "- " << idx.data(NotificationsModel::AppNameModelRole).toString()
|
||||
<< ": " << 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;
|
||||
} else {
|
||||
QTextStream(stderr) << i18n("Nothing to be done") << endl;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ LanLinkProvider::LanLinkProvider()
|
|||
|
||||
LanLinkProvider::~LanLinkProvider()
|
||||
{
|
||||
|
||||
delete m_pairingHandler;
|
||||
}
|
||||
|
||||
void LanLinkProvider::onStart()
|
||||
|
|
|
@ -469,7 +469,7 @@ void Device::setAsPaired()
|
|||
m_pairingTimeout.stop(); //Just in case it was started
|
||||
|
||||
//Save device info in the config
|
||||
KdeConnectConfig::instance()->addTrustedDevice(id(), name(), type2str(m_deviceType), m_publicKey.toPEM(), QString(m_certificate.toPem()));
|
||||
KdeConnectConfig::instance()->addTrustedDevice(id(), name(), type2str(m_deviceType), m_publicKey.toPEM(), QString::fromLatin1(m_certificate.toPem()));
|
||||
|
||||
reloadPlugins(); //Will actually load the plugins
|
||||
|
||||
|
|
|
@ -87,6 +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
|
||||
QString iconName() const;
|
||||
QString statusIconName() const;
|
||||
|
||||
|
|
|
@ -112,8 +112,7 @@ KdeConnectConfig::KdeConnectConfig()
|
|||
QFile cert(certPath);
|
||||
if (cert.exists() && cert.open(QIODevice::ReadOnly)) {
|
||||
|
||||
// d->certificate = QCA::Certificate::fromPEMFile(certPath);
|
||||
d->certificate = QSslCertificate::fromPath(certPath).value(0);
|
||||
d->certificate = QSslCertificate::fromPath(certPath).first();
|
||||
|
||||
} else {
|
||||
|
||||
|
|
Loading…
Reference in a new issue