mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Close #401: Write PEM data to a file especially for crlgen
The new option --pem-file=<filename> behaves like --pem, just that it writes the PEM data (and nothing else) to the given file name
This commit is contained in:
parent
e1fbba9eaa
commit
6777f7c853
@ -54,6 +54,8 @@ const QList<arg_option> arguments::opts = {
|
||||
"Database password for unlocking the database. See below for password format options."),
|
||||
arg_option("pem", NULL, no_argument, true, false,
|
||||
"Print PEM representation of provided files. Prints only the public part of private keys."),
|
||||
arg_option("pem-file", NULL, file_argument, true, false,
|
||||
"Specify a file name for the PEM data. Implies '--pem'."),
|
||||
arg_option("print", NULL, no_argument, true, false,
|
||||
"Print a synopsis of provided files."),
|
||||
arg_option("select", "id-list", required_argument, true, true,
|
||||
|
||||
@ -242,7 +242,7 @@ int read_cmdline(int argc, char *argv[], bool console_only,
|
||||
}
|
||||
}
|
||||
|
||||
BioByteArray bba;
|
||||
BioByteArray bba, bbafile;
|
||||
foreach(pki_base *pki, cmdline_items->get()) {
|
||||
QString filename = pki->getFilename();
|
||||
if ((cmd_opts.has("text") || cmd_opts.has("print")) &&
|
||||
@ -255,11 +255,25 @@ int read_cmdline(int argc, char *argv[], bool console_only,
|
||||
pki->print(bba, pki_base::print_coloured);
|
||||
if (cmd_opts.has("text"))
|
||||
pki->print(bba, pki_base::print_openssl_txt);
|
||||
if (cmd_opts.has("pem"))
|
||||
if (cmd_opts.has("pem-file"))
|
||||
pki->print(bbafile, pki_base::print_pem);
|
||||
else if (cmd_opts.has("pem"))
|
||||
pki->print(bba, pki_base::print_pem);
|
||||
}
|
||||
if (bba.size() > 0)
|
||||
console_write(stdout, bba);
|
||||
|
||||
if (bbafile.size() > 0)
|
||||
{
|
||||
QString filename = cmd_opts["pem-file"];
|
||||
XFile f(filename);
|
||||
if (f.open_write())
|
||||
f.write(bbafile);
|
||||
else
|
||||
XCA_ERROR(QObject::tr("Failed to write PEM data to '%1'")
|
||||
.arg(filename));
|
||||
f.close();
|
||||
}
|
||||
if (cmd_opts.has("import")) {
|
||||
Database.insert(cmdline_items);
|
||||
*_cmdline_items = nullptr;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user