andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0025-Issue-50850-Fix-dsctl-healthcheck-for-python36.patch

8394b4
From b941befe083a02ed0e4d5bc6c3c50f1a82f04012 Mon Sep 17 00:00:00 2001
8394b4
From: Mark Reynolds <mreynolds@redhat.com>
8394b4
Date: Thu, 23 Jan 2020 12:22:21 -0500
8394b4
Subject: [PATCH] Issue 50850 - Fix dsctl healthcheck for python36
8394b4
8394b4
Description:  dsctl health check, specifically the certificate expiring
8394b4
              checks, were using python37 specific functions, but these
8394b4
              do not work on python36.  Needed to replace fromisoformat()
8394b4
              with something more portable.
8394b4
8394b4
relates: https://pagure.io/389-ds-base/issue/50850
8394b4
8394b4
Reviewed by: firstyear(Thanks!)
8394b4
---
8394b4
 src/lib389/lib389/nss_ssl.py | 8 +++++---
8394b4
 1 file changed, 5 insertions(+), 3 deletions(-)
8394b4
8394b4
diff --git a/src/lib389/lib389/nss_ssl.py b/src/lib389/lib389/nss_ssl.py
8394b4
index 2a7d1637c..41b19caa4 100644
8394b4
--- a/src/lib389/lib389/nss_ssl.py
8394b4
+++ b/src/lib389/lib389/nss_ssl.py
8394b4
@@ -79,13 +79,15 @@ class NssSsl(object):
8394b4
             cert_list.append(self.get_cert_details(cert[0]))
8394b4
 
8394b4
         for cert in cert_list:
8394b4
-            if date.fromisoformat(cert[3].split()[0]) - date.today() < timedelta(days=0):
8394b4
+            cert_date = cert[3].split()[0]
8394b4
+            diff_date = datetime.strptime(cert_date, '%Y-%m-%d').date() - datetime.today().date()
8394b4
+            if diff_date < timedelta(days=0):
8394b4
                 # Expired
8394b4
                 report = copy.deepcopy(DSCERTLE0002)
8394b4
                 report['detail'] = report['detail'].replace('CERT', cert[0])
8394b4
                 yield report
8394b4
-            elif date.fromisoformat(cert[3].split()[0]) - date.today() < timedelta(days=30):
8394b4
-                # Expiring
8394b4
+            elif diff_date < timedelta(days=30):
8394b4
+                # Expiring within 30 days
8394b4
                 report = copy.deepcopy(DSCERTLE0001)
8394b4
                 report['detail'] = report['detail'].replace('CERT', cert[0])
8394b4
                 yield report
8394b4
-- 
8394b4
2.21.1
8394b4