Commit 95416fb1 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Create OpenPGP certificate by default with --gen-key

Create an OpenPGP certificate directly using the corresponding command
unless the CMS protocol is explicitly requested with --gen-key.
Additionally, check whether the creation of an S/MIME CSR is allowed,
and return with an error if it isn't allowed.

GnuPG-bug-id: 5832
parent b39f97df
......@@ -47,6 +47,7 @@
#include "commands/checksumverifyfilescommand.h"
#include "commands/detailscommand.h"
#include "commands/newcertificatecommand.h"
#include "commands/newopenpgpcertificatecommand.h"
#include "dialogs/updatenotification.h"
......@@ -468,10 +469,21 @@ QString KleopatraApplication::newInstance(const QCommandLineParser &parser,
// Check for --gen-key command
if (parser.isSet(QStringLiteral("gen-key"))) {
auto cmd = new NewCertificateCommand(nullptr);
cmd->setParentWId(parentId);
cmd->setProtocol(protocol);
cmd->start();
if (protocol == GpgME::CMS) {
const Kleo::Settings settings{};
if (settings.cmsEnabled() && settings.cmsCertificateCreationAllowed()) {
auto cmd = new NewCertificateCommand(nullptr);
cmd->setParentWId(parentId);
cmd->setProtocol(protocol);
cmd->start();
} else {
return i18n("You are not allowed to create S/MIME certificate signing requests.");
}
} else {
auto cmd = new NewOpenPGPCertificateCommand;
cmd->setParentWId(parentId);
cmd->start();
}
return QString();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment