mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Extend generating an OpenSSL "index.txt"
Updated patch adds another export option automating the creation of multiple index.txt files to be used with multiple ocsp responders. New export option is available via command line (-I index.txt) and the Extras menu (Extra->Export Certificate Index hierarchy). The option causes the creation of an index.txt file containing index records for all the children certificates of a parent. The filenames are generated using the supplied name as prefix and append a dot and the simplified Internal Name (the Internal Name stripped of non-alphanumeric characters except underscores).
This commit is contained in:
parent
15845796cd
commit
0d34bc1c1c
@ -165,6 +165,15 @@ QString a1time::toPlain() const
|
||||
return toUTC().toString(GEN_FORMAT);
|
||||
}
|
||||
|
||||
QString a1time::toPlainUTC() const
|
||||
{
|
||||
if (isUndefined())
|
||||
return QString(UNDEFINED_DATE);
|
||||
if (!isValid())
|
||||
return QString("Broken-InvalidZ");
|
||||
return toUTC().toString(UTC_FORMAT);
|
||||
}
|
||||
|
||||
QString a1time::toSortable() const
|
||||
{
|
||||
if (isUndefined())
|
||||
|
||||
@ -34,6 +34,7 @@ class a1time : public QDateTime
|
||||
QString toPretty() const;
|
||||
QString toPrettyGMT() const;
|
||||
QString toPlain() const;
|
||||
QString toPlainUTC() const;
|
||||
QString toSortable() const;
|
||||
ASN1_TIME *get();
|
||||
ASN1_TIME *get_utc();
|
||||
|
||||
@ -307,12 +307,28 @@ QList<pki_x509*> db_x509::getCerts(bool onlyTrusted)
|
||||
return c;
|
||||
}
|
||||
|
||||
void db_x509::writeIndex(const QString fname)
|
||||
void db_x509::writeIndex(const QString fname, bool hierarchy)
|
||||
{
|
||||
bool append = false;
|
||||
FOR_ALL_pki(pki, pki_x509) {
|
||||
pki->writeIndexEntry(fname, append);
|
||||
append = true;
|
||||
if (hierarchy) {
|
||||
FOR_ALL_pki(pki, pki_x509) {
|
||||
if (pki->childCount()) {
|
||||
|
||||
QString newfname = fname + "." + pki->getIntName().replace(QRegExp("[^a-zA-Z0-9]"),QString(""));;
|
||||
|
||||
append = false;
|
||||
foreach(pki_base *_child, pki->childItems) {
|
||||
pki_x509 *child = static_cast<pki_x509*>(_child);
|
||||
child->writeIndexEntry(newfname, append);
|
||||
append = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FOR_ALL_pki(pki, pki_x509) {
|
||||
pki->writeIndexEntry(fname, append);
|
||||
append = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ class db_x509: public db_x509super
|
||||
QList<pki_x509*> getCerts(bool onlyTrusted);
|
||||
a1int searchSerial(pki_x509 *signer);
|
||||
void writeAllCerts(const QString fname, bool onlyTrusted);
|
||||
void writeIndex(const QString fname);
|
||||
void writeIndex(const QString fname, bool hierarchy);
|
||||
pki_x509 *getByIssSerial(const pki_x509 *issuer, const a1int &a);
|
||||
pki_x509 *getBySubject(const x509name &xname, pki_x509 *last = NULL);
|
||||
pki_base *insert(pki_base *item);
|
||||
|
||||
@ -596,8 +596,8 @@ void pki_x509::writeIndexEntry(FILE *fp)
|
||||
flag = "E";
|
||||
|
||||
QString line = QString("%1\t%2\t%3\t%4\tunknown\t%5\n").arg(
|
||||
flag, getNotAfter().toPlain(), (revoked ? revocation.getDate().toPlain() : ""),
|
||||
getSerial().toHex(), getSubject().oneLine(XN_FLAG_ONELINE));
|
||||
flag, getNotAfter().toPlainUTC(), (revoked ? revocation.getDate().toPlainUTC() : ""),
|
||||
getSerial().toHex(), QString(X509_NAME_oneline(getSubject().get(), NULL, 0)));
|
||||
|
||||
QByteArray ba = line.toUtf8();
|
||||
fwrite(ba.constData(), ba.size(), 1, fp);
|
||||
|
||||
@ -33,6 +33,7 @@ void MainWindow::cmd_help(const char* msg) {
|
||||
" -e <type>:<name> extract entry.\n"
|
||||
" -d expect the following argument to be the database name to use\n"
|
||||
" -i expect the following argument to be the index file to generate\n"
|
||||
" -I expect the following argument to be the base name the index file hierarchy to generate\n"
|
||||
" -x Exit after processing all commandline options\n\n");
|
||||
|
||||
if(msg) {
|
||||
|
||||
@ -140,6 +140,8 @@ void MainWindow::init_menu()
|
||||
SLOT(dump_database()));
|
||||
acList += extra->addAction(tr("&Export Certificate Index"), this,
|
||||
SLOT(exportIndex()));
|
||||
acList += extra->addAction(tr("&Export Certificate Index hierarchy"), this,
|
||||
SLOT(exportIndexHierarchy()));
|
||||
acList += extra->addAction(tr("C&hange DataBase password"), this,
|
||||
SLOT(changeDbPass()));
|
||||
acList += extra->addAction(tr("&Import old db_dump"), this,
|
||||
|
||||
@ -281,6 +281,9 @@ void MainWindow::read_cmdline(int argc, char *argv[])
|
||||
case 'i':
|
||||
export_index=1;
|
||||
break;
|
||||
case 'I':
|
||||
export_index=2;
|
||||
break;
|
||||
case 'v':
|
||||
cmd_version();
|
||||
opt=0;
|
||||
@ -309,7 +312,7 @@ void MainWindow::read_cmdline(int argc, char *argv[])
|
||||
exitApp = 1;
|
||||
force_load = 0;
|
||||
} else if (export_index) {
|
||||
if (exportIndex(file) == 2)
|
||||
if (exportIndex(file, (export_index == 2)) == 2)
|
||||
exitApp = 1;
|
||||
export_index = 0;
|
||||
} else {
|
||||
@ -866,10 +869,15 @@ pki_multi *MainWindow::probeAnything(QString file, int *ret)
|
||||
|
||||
void MainWindow::exportIndex()
|
||||
{
|
||||
exportIndex(NULL);
|
||||
exportIndex(NULL, false);
|
||||
}
|
||||
|
||||
int MainWindow::exportIndex(QString fname)
|
||||
void MainWindow::exportIndexHierarchy()
|
||||
{
|
||||
exportIndex(NULL, true);
|
||||
}
|
||||
|
||||
int MainWindow::exportIndex(QString fname, bool hierarchy)
|
||||
{
|
||||
if (fname == NULL || fname.isEmpty()) {
|
||||
|
||||
@ -889,7 +897,17 @@ int MainWindow::exportIndex(QString fname)
|
||||
return 2;
|
||||
}
|
||||
|
||||
certs->writeIndex(fname);
|
||||
bool needChangeView = hierarchy && !certs->treeview;
|
||||
if (needChangeView) {
|
||||
certView->changeView();
|
||||
}
|
||||
|
||||
certs->writeIndex(fname, hierarchy);
|
||||
|
||||
if (needChangeView) {
|
||||
certView->changeView();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
QStringList urlsToOpen;
|
||||
int checkOldGetNewPass(Passwd &pass);
|
||||
QString updateDbPassword(QString newdb, Passwd pass);
|
||||
int exportIndex(QString fname);
|
||||
int exportIndex(QString fname, bool hierarchy);
|
||||
|
||||
protected:
|
||||
void init_images();
|
||||
@ -167,6 +167,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
void openURLs();
|
||||
void changeEvent(QEvent *event);
|
||||
void exportIndex();
|
||||
void exportIndexHierarchy();
|
||||
|
||||
protected slots:
|
||||
void closeEvent(QCloseEvent * event);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user