mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Close #423: parameter --name is not respected when running with CLI
Evaluate --name argument when generating the CRL. Add --import-names option. This allows to name the imported items individually, even if one PEM file contains multiple items.
This commit is contained in:
parent
7b2342f5cd
commit
e39be9b4e9
@ -34,6 +34,8 @@ const QList<arg_option> arguments::opts = {
|
||||
"Save OpenSSL index in <file>."),
|
||||
arg_option("import", NULL, no_argument, false, true,
|
||||
"Import all provided items into the database."),
|
||||
arg_option("import-names", NULL, required_argument, false, true,
|
||||
"A semicolon separated list of names applied to the imported items in the order found in the PEM file and on the commandline."),
|
||||
arg_option("issuers", NULL, no_argument, true, true,
|
||||
"Print all known issuer certificates that have an associated private key and the CA basic constraints set to 'true'."),
|
||||
arg_option("keygen", "type", required_argument, true, true,
|
||||
|
||||
@ -125,7 +125,7 @@ void db_crl::exportItems(const QModelIndexList &indexes,
|
||||
writeVcalendar(file, vcal);
|
||||
}
|
||||
|
||||
pki_crl *db_crl::newCrl(const crljob &task)
|
||||
pki_crl *db_crl::newCrl(const crljob &task, QString name)
|
||||
{
|
||||
pki_crl *crl = NULL;
|
||||
pki_x509 *cert = task.issuer;
|
||||
@ -137,8 +137,10 @@ pki_crl *db_crl::newCrl(const crljob &task)
|
||||
X509V3_set_ctx_nodb(&ext_ctx);
|
||||
XSqlQuery q;
|
||||
|
||||
if (name.isEmpty())
|
||||
name = cert->getIntName();
|
||||
crl = new pki_crl();
|
||||
crl->createCrl(cert->getIntName(), cert);
|
||||
crl->createCrl(name, cert);
|
||||
crl->pkiSource = generated;
|
||||
|
||||
foreach(x509rev rev, cert->getRevList())
|
||||
|
||||
@ -24,7 +24,7 @@ class db_crl: public db_x509name
|
||||
pki_base *insert(pki_base *item);
|
||||
void removeSigner(pki_base *signer);
|
||||
void updateCertView();
|
||||
pki_crl *newCrl(const crljob &crljob);
|
||||
pki_crl *newCrl(const crljob &crljob, QString name = QString());
|
||||
void exportItems(const QModelIndexList &indexes,
|
||||
const pki_export *xport, XFile &file) const;
|
||||
};
|
||||
|
||||
10
lib/main.cpp
10
lib/main.cpp
@ -307,6 +307,14 @@ static void read_cmdline(int argc, char *argv[], bool console_only)
|
||||
qDebug() << "Probe" << file;
|
||||
cmdline_items->probeAnything(file);
|
||||
}
|
||||
QStringList names = cmd_opts["import-names"].split(";");
|
||||
foreach(pki_base *pki, cmdline_items->get()) {
|
||||
if (names.isEmpty())
|
||||
break;
|
||||
QString name = names.takeFirst();
|
||||
if (!name.isEmpty())
|
||||
pki->setIntName(name);
|
||||
}
|
||||
if (cmdline_items->failed_files.size() > 0) {
|
||||
XCA_WARN(QString("Failed to import from '%1'")
|
||||
.arg(cmdline_items->failed_files.join("' '")));
|
||||
@ -419,7 +427,7 @@ static void read_cmdline(int argc, char *argv[], bool console_only)
|
||||
.arg(cmd_opts["crlgen"]));
|
||||
} else {
|
||||
crljob task(issuer);
|
||||
pki_crl *crl = crls->newCrl(task);
|
||||
pki_crl *crl = crls->newCrl(task, cmd_opts["name"]);
|
||||
if (crl)
|
||||
cmdline_items->append_item(crl);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ void pki_multi::append_item(pki_base *pki)
|
||||
{
|
||||
pki_multi *m = dynamic_cast<pki_multi*>(pki);
|
||||
if (m)
|
||||
multi += m;
|
||||
multi += m->multi;
|
||||
else
|
||||
multi << pki;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user