From 8af3cabfa8f9cd191e93a289f878a1c93e72d667 Mon Sep 17 00:00:00 2001 From: pf Date: Mon, 31 May 2021 23:52:06 +0300 Subject: [PATCH] Replace certificate while renewing it This commit also changes the default state of the "Revoke old certificate" checkbox to unchecked. The reasoning for this is that by renewing a certificate its lifetime and subsequently validity are prolonged, which therefore implies equal trustworthiness for both new and old certificates, which does not intend the revocation of the latter. --- lib/db_x509.cpp | 6 ++++++ ui/CertExtend.ui | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/db_x509.cpp b/lib/db_x509.cpp index 5288efcc..3813c212 100644 --- a/lib/db_x509.cpp +++ b/lib/db_x509.cpp @@ -837,6 +837,7 @@ void db_x509::certRenewal(QModelIndexList indexes) CertExtend *dlg = NULL; x509rev r; bool doRevoke = false; + bool doReplace = false; if (indexes.size() == 0) return; @@ -862,6 +863,7 @@ void db_x509::certRenewal(QModelIndexList indexes) r = revoke->getRevocation(); delete revoke; } + doReplace = dlg->replace->isChecked(); foreach(idx, indexes) { oldcert = fromIndex(idx); if (!oldcert) @@ -887,6 +889,10 @@ void db_x509::certRenewal(QModelIndexList indexes) newcert->sign(signkey, oldcert->getDigest()); newcert = dynamic_cast(insert(newcert)); createSuccess(newcert); + + // delete old certificate if requested + if (doReplace) + deletePKI(idx); } if (doRevoke) do_revoke(indexes, r); diff --git a/ui/CertExtend.ui b/ui/CertExtend.ui index be5f3f28..91902f43 100644 --- a/ui/CertExtend.ui +++ b/ui/CertExtend.ui @@ -215,6 +215,16 @@ Revoke old certificate + + false + + + + + + + Replace old certificate + true