Mercurial > trustbridge
changeset 683:05953583a738
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Mon, 30 Jun 2014 19:04:15 +0200 |
parents | 578860edde53 (current diff) 5e25159d7025 (diff) |
children | 69def231f5ac |
files | |
diffstat | 3 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/administratorwindow.cpp Mon Jun 30 18:59:31 2014 +0200 +++ b/ui/administratorwindow.cpp Mon Jun 30 19:04:15 2014 +0200 @@ -224,7 +224,7 @@ } } -void AdministratorWindow::logChanges(const QString ¤tCerts) +void AdministratorWindow::logChanges(const QString ¤tCerts, const QString& keyFingerprint) { QDir logDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); QString logFilePath = logDir.filePath("log.txt"); @@ -239,7 +239,7 @@ CertificateList newCertList; newCertList.readList(currentCerts.toLocal8Bit()); - QByteArray entries = createLogEntries(newCertList); + QByteArray entries = createLogEntries(newCertList, keyFingerprint); if(logFile.write(entries) != entries.size()) { QMessageBox::warning(this, tr("Error!"), tr("Failed to write log file: ") + logFilePath + tr(" Changes are not logged!")); @@ -248,7 +248,7 @@ logFile.close(); } -QByteArray AdministratorWindow::createLogEntries(const CertificateList &list) +QByteArray AdministratorWindow::createLogEntries(const CertificateList &list, const QString& keyFingerprint) { QByteArray entries; QByteArray removeListEntries; @@ -265,7 +265,9 @@ listDate.toString(Qt::ISODate) + "#####\r\n"); entries.append(tr("signing certificate: \r\n")); - entries.append(tr("new certificates:\r\n")); + entries.append(keyFingerprint); + + entries.append(tr("\r\nnew certificates:\r\n")); foreach (const Certificate& cert, list.getCertificates()) { if (!mCertList.getCertificates().contains(cert)) {
--- a/ui/administratorwindow.h Mon Jun 30 18:59:31 2014 +0200 +++ b/ui/administratorwindow.h Mon Jun 30 19:04:15 2014 +0200 @@ -48,8 +48,9 @@ * saved as current. * * @param currentCerts Path to the current certificate list file. + * @param certFingerprint The fingerprint of the signing key used. */ - void logChanges(const QString ¤tCerts); + void logChanges(const QString ¤tCerts, const QString &keyFingerprint); /** @brief get the currently changed certificates. * @return a list of certificates. @@ -71,7 +72,7 @@ void createContent(); void loadCertificateTable(); void addToCertificateTable(const QList<Certificate> &certs); - QByteArray createLogEntries(const CertificateList &list); + QByteArray createLogEntries(const CertificateList &list, const QString &keyFingerprint); QSettings mSettings;
--- a/ui/createcertlistdialog.cpp Mon Jun 30 18:59:31 2014 +0200 +++ b/ui/createcertlistdialog.cpp Mon Jun 30 19:04:15 2014 +0200 @@ -272,7 +272,33 @@ return; } + + QString keyFingerprint; + + { + /* Calculate sha256 sum of the der key */ + unsigned char output_buf[16000]; /* Buf size taken from examples */ + int ret; + ret = pk_write_key_der (mPk, output_buf, 16000); + if (ret <= 0) { + showErrorMessage(tr("Failed to calculate key hash.")); + return; + } + QByteArray derKey((const char*)output_buf, ret); + QByteArray fp = sha256sum(derKey); + + for (int i=0; i < fp.size(); i++) { + keyFingerprint += QString("%1").arg( + (unsigned char)(fp[i]), 0, 16).rightJustified(2, '0'); + if (i != fp.size() - 1) { + keyFingerprint += ":"; + } + } + keyFingerprint = keyFingerprint.toUpper(); + } + + mAdminWindow->logChanges(curCerts, keyFingerprint); + QMessageBox::information(this, "", tr("Saved certificate list:\n%1").arg(fileName)); - mAdminWindow->logChanges(curCerts); close(); }