diff --git a/lib/pki_export.cpp b/lib/pki_export.cpp index 21af6c7c..98b665b5 100644 --- a/lib/pki_export.cpp +++ b/lib/pki_export.cpp @@ -100,7 +100,7 @@ new pki_export(32, revocation, "crl", "PEM", F_PEM, tr("PEM new pki_export(33, revocation, "der", "DER", F_DER | F_SINGLE, tr("Binary DER format of the revocation list")), new pki_export(34, revocation, "ics", tr("vCalendar"), F_CAL, tr("vCalendar reminder for the CRL expiry date")), -new pki_export(35, tmpl, "xca", "PEM", F_PEM | F_SINGLE, tr("XCA template in PEM-like format")), -new pki_export(36, tmpl, "pem", "PEM", F_PEM | F_MULTI, tr("All selected XCA templates in PEM-like format")), +new pki_export(35, tmpl, "xca", "PEM", F_PEM | F_SINGLE, tr("XCA template in PEM-like format. Templates include the internal name and comment")), +new pki_export(36, tmpl, "pem", "PEM", F_PEM | F_MULTI, tr("All selected XCA templates in PEM-like format. Templates include the internal name and comment")), }; } diff --git a/lib/pki_temp.cpp b/lib/pki_temp.cpp index fd76e11d..2dfab297 100644 --- a/lib/pki_temp.cpp +++ b/lib/pki_temp.cpp @@ -363,7 +363,7 @@ void pki_temp::old_fromData(const unsigned char *p, int size, int version) } } -QByteArray pki_temp::toData() const +QByteArray pki_temp::toData(bool for_export) const { QByteArray ba; @@ -373,6 +373,12 @@ QByteArray pki_temp::toData() const buf.open(QIODevice::WriteOnly | QIODevice::Append); QDataStream out(&buf); out.setVersion(TEMPLATE_DS_VERSION); + if (for_export) { + out << QMap{ + { "internal_name", getIntName() }, + { "internal_comment", getComment() } + }; + } out << settings; buf.close(); return ba; @@ -394,6 +400,14 @@ void pki_temp::fromData(QByteArray &ba, int version) if (settings.contains(key)) settings[translate[key]] = settings.take(key); } + if (settings.contains("internal_name")) { + qDebug() << "Import internal_name" << settings["internal_name"]; + setIntName(settings.take("internal_name")); + } + if (settings.contains("internal_comment")) { + qDebug() << "Import internal_comment" << settings["internal_comment"]; + setComment(settings.take("internal_comment")); + } buf.close(); (void)version; //if (version < 11) .... @@ -414,7 +428,7 @@ QByteArray pki_temp::toExportData() const QByteArray data, header; BioByteArray b; - data = toData(); + data = toData(true); header = db::intToData(data.size()); header += db::intToData(TMPL_VERSION); header += data; @@ -485,7 +499,7 @@ void pki_temp::fload(const QString &fname) } } -void pki_temp::fromPEM_BIO(BIO *bio, const QString &name) +void pki_temp::fromPEM_BIO(BIO *bio, const QString &) { QByteArray ba; QString msg; @@ -502,7 +516,6 @@ void pki_temp::fromPEM_BIO(BIO *bio, const QString &name) if (!strcmp(nm, PEM_STRING_XCA_TEMPLATE)) { ba = QByteArray::fromRawData((char*)data, len); fromExportData(ba); - setIntName(rmslashdot(name)); } else { msg = tr("Not an XCA Template, but '%1'").arg(nm); } @@ -529,3 +542,11 @@ QVariant pki_temp::getIcon(const dbheader *hd) const return hd->id == HD_internal_name ? QVariant(QPixmap(":templateIco")) : QVariant(); } + +void pki_temp::autoIntName(const QString &file) +{ + if (getIntName().isEmpty()) + setIntName(rmslashdot(file)); + if (getIntName().isEmpty()) + pki_x509name::autoIntName(file); +} diff --git a/lib/pki_temp.h b/lib/pki_temp.h index 3893e05b..4a6e2c52 100644 --- a/lib/pki_temp.h +++ b/lib/pki_temp.h @@ -70,7 +70,7 @@ class pki_temp: public pki_x509name pre_defined = true; } QString comboText() const; - QByteArray toData() const; + QByteArray toData(bool for_export = false) const; QString toB64Data() { return QString::fromLatin1(toData().toBase64()); @@ -92,6 +92,7 @@ class pki_temp: public pki_x509name QSqlError insertSqlData(); QSqlError deleteSqlData(); void restoreSql(const QSqlRecord &rec); + void autoIntName(const QString &file); }; Q_DECLARE_METATYPE(pki_temp *); diff --git a/ui/CertDetail.ui b/ui/CertDetail.ui index eba5d9c0..ce91a963 100644 --- a/ui/CertDetail.ui +++ b/ui/CertDetail.ui @@ -108,7 +108,7 @@ - + The internal name of the certificate in the database diff --git a/ui/CrlDetail.ui b/ui/CrlDetail.ui index fb0bc1e0..ebe2bc0a 100644 --- a/ui/CrlDetail.ui +++ b/ui/CrlDetail.ui @@ -179,7 +179,7 @@ - + The internal name of the CRL in the database diff --git a/ui/ExportDialog.ui b/ui/ExportDialog.ui index a2d19d49..06673b93 100644 --- a/ui/ExportDialog.ui +++ b/ui/ExportDialog.ui @@ -77,7 +77,7 @@ - + The internal name of the CRL in the database diff --git a/ui/KeyDetail.ui b/ui/KeyDetail.ui index 6fa6bd62..f6aca0b6 100644 --- a/ui/KeyDetail.ui +++ b/ui/KeyDetail.ui @@ -84,7 +84,7 @@ - + The internal name of the key used by xca diff --git a/widgets/CertDetail.cpp b/widgets/CertDetail.cpp index 28a6369b..97105cd3 100644 --- a/widgets/CertDetail.cpp +++ b/widgets/CertDetail.cpp @@ -41,7 +41,7 @@ void CertDetail::on_showExt_clicked() void CertDetail::setX509super(pki_x509super *x) { - descr->setText(x->getIntName()); + description->setText(x->getIntName()); thisSqlId = x->getSqlItemId(); connect_pki(x); @@ -262,7 +262,7 @@ void CertDetail::itemChanged(pki_base *pki) if (pkiSqlId == issuerSqlId) signature->setText(pki->getIntName()); if (pkiSqlId == thisSqlId) - descr->setText(pki->getIntName()); + description->setText(pki->getIntName()); } void CertDetail::showPubKey() diff --git a/widgets/CrlDetail.cpp b/widgets/CrlDetail.cpp index b5ef2f5e..eb54c68a 100644 --- a/widgets/CrlDetail.cpp +++ b/widgets/CrlDetail.cpp @@ -62,7 +62,7 @@ void CrlDetail::setCrl(pki_crl *crl) connect(issuerIntName, SIGNAL(doubleClicked(QString)), this, SLOT(showIssuer())); - descr->setText(crl->getIntName()); + description->setText(crl->getIntName()); lUpdate->setText(crl->getLastUpdate().toPretty()); lUpdate->setToolTip(crl->getLastUpdate().toPrettyGMT()); nUpdate->setText(crl->getNextUpdate().toPretty()); @@ -85,7 +85,7 @@ void CrlDetail::itemChanged(pki_base *pki) if (pkiSqlId == issuerSqlId) issuerIntName->setText(pki->getIntName()); if (pkiSqlId == crlSqlId) - descr->setText(pki->getIntName()); + description->setText(pki->getIntName()); } void CrlDetail::showIssuer() diff --git a/widgets/ExportDialog.cpp b/widgets/ExportDialog.cpp index 9b5ca5a7..b06f7632 100644 --- a/widgets/ExportDialog.cpp +++ b/widgets/ExportDialog.cpp @@ -32,11 +32,11 @@ ExportDialog::ExportDialog(QWidget *w, const QString &title, if (indexes.size() == 1) { pki_base *pki = db_base::fromIndex(indexes[0]); if (pki) { - descr->setText(pki->getIntName()); + description->setText(pki->getIntName()); fname = pki->getUnderlinedName(); } } - descr->setReadOnly(true); + description->setReadOnly(true); image->setPixmap(img); label->setText(title); mainwin->helpdlg->register_ctxhelp_button(this, help_ctx); diff --git a/widgets/KeyDetail.cpp b/widgets/KeyDetail.cpp index 311a2eef..2dcae74f 100644 --- a/widgets/KeyDetail.cpp +++ b/widgets/KeyDetail.cpp @@ -73,7 +73,7 @@ void KeyDetail::setupFingerprints(pki_key *key) void KeyDetail::setKey(pki_key *key, bool import) { keySqlId = key->getSqlItemId(); - descr->setText(key->getIntName()); + description->setText(key->getIntName()); keyLength->setText(key->length()); if (import) connect_pki(key); @@ -147,7 +147,7 @@ void KeyDetail::setKey(pki_key *key, bool import) void KeyDetail::itemChanged(pki_base *pki) { if (pki->getSqlItemId() == keySqlId) - descr->setText(pki->getIntName()); + description->setText(pki->getIntName()); } void KeyDetail::showKey(QWidget *parent, pki_key *key, bool import) @@ -157,7 +157,7 @@ void KeyDetail::showKey(QWidget *parent, pki_key *key, bool import) KeyDetail *dlg = new KeyDetail(parent); bool ro = !key->getSqlItemId().isValid(); dlg->setKey(key, import); - dlg->descr->setReadOnly(ro); + dlg->description->setReadOnly(ro); dlg->comment->setReadOnly(ro); dlg->exec(); diff --git a/widgets/XcaDetail.cpp b/widgets/XcaDetail.cpp index edba42ae..3a42fb7d 100644 --- a/widgets/XcaDetail.cpp +++ b/widgets/XcaDetail.cpp @@ -56,9 +56,9 @@ void XcaDetail::updateNameComment() { if (!pki) return; - QLineEdit *descr = findChild("descr"); - if (descr) - pki->setIntName(descr->text()); + QLineEdit *description = findChild("description"); + if (description) + pki->setIntName(description->text()); QTextEdit *comment = findChild("comment"); if (comment) pki->setComment(comment->toPlainText()); @@ -79,9 +79,9 @@ void XcaDetail::import() if (buttonBox && !pki && importbut) { buttonBox->removeButton(importbut); importbut = nullptr; - QLineEdit *descr = findChild("descr"); - if (descr) - descr->setReadOnly(true); + QLineEdit *description = findChild("description"); + if (description) + description->setReadOnly(true); QTextEdit *comment = findChild("comment"); if (comment) comment->setReadOnly(true);