Blame SOURCES/0002-Correct-certificate-lifetime-calculation.patch

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