|
|
8e2324 |
From 87604820a935f87a8f533e3f294419d27c0514eb Mon Sep 17 00:00:00 2001
|
|
|
8e2324 |
From: Allison Karlitskaya <allison.karlitskaya@redhat.com>
|
|
|
8e2324 |
Date: Tue, 26 Oct 2021 12:32:13 +0200
|
|
|
8e2324 |
Subject: [PATCH 2/2] Correct certificate lifetime calculation
|
|
|
8e2324 |
|
|
|
8e2324 |
sscg allows passing the certificate lifetime, as a number of days, as a
|
|
|
8e2324 |
commandline argument. It converts this value to seconds using the
|
|
|
8e2324 |
formula
|
|
|
8e2324 |
|
|
|
8e2324 |
days * 24 * 3650
|
|
|
8e2324 |
|
|
|
8e2324 |
which is incorrect. The correct value is 3600.
|
|
|
8e2324 |
|
|
|
8e2324 |
This effectively adds an extra 20 minutes to the lifetime of the
|
|
|
8e2324 |
certificate for each day as given on the commandline, and was enough to
|
|
|
8e2324 |
cause some new integration tests in cockpit to fail.
|
|
|
8e2324 |
|
|
|
8e2324 |
Interestingly, 3650 is the old default value for the number of days of
|
|
|
8e2324 |
certificate validity (~10 years) so this probably slipped in as a sort
|
|
|
8e2324 |
of muscle-memory-assisted typo.
|
|
|
8e2324 |
|
|
|
8e2324 |
Let's just write `24 * 60 * 60` to make things clear.
|
|
|
8e2324 |
---
|
|
|
8e2324 |
src/x509.c | 2 +-
|
|
|
8e2324 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
8e2324 |
|
|
|
8e2324 |
diff --git a/src/x509.c b/src/x509.c
|
|
|
8e2324 |
index dc1594a4bdcb9d81607f0fe5ad2d4562e5edb533..7c7e4dfe56d5756862f3e0f851941e846ce96f31 100644
|
|
|
8e2324 |
--- a/src/x509.c
|
|
|
8e2324 |
+++ b/src/x509.c
|
|
|
8e2324 |
@@ -416,11 +416,11 @@ sscg_sign_x509_csr (TALLOC_CTX *mem_ctx,
|
|
|
8e2324 |
X509_set_issuer_name (cert, X509_REQ_get_subject_name (csr));
|
|
|
8e2324 |
}
|
|
|
8e2324 |
|
|
|
8e2324 |
/* set time */
|
|
|
8e2324 |
X509_gmtime_adj (X509_get_notBefore (cert), 0);
|
|
|
8e2324 |
- X509_gmtime_adj (X509_get_notAfter (cert), days * 24 * 3650);
|
|
|
8e2324 |
+ X509_gmtime_adj (X509_get_notAfter (cert), days * 24 * 60 * 60);
|
|
|
8e2324 |
|
|
|
8e2324 |
/* set subject */
|
|
|
8e2324 |
subject = X509_NAME_dup (X509_REQ_get_subject_name (csr));
|
|
|
8e2324 |
sslret = X509_set_subject_name (cert, subject);
|
|
|
8e2324 |
CHECK_SSL (sslret, X509_set_subject_name);
|
|
|
8e2324 |
--
|
|
|
8e2324 |
2.33.0
|
|
|
8e2324 |
|