Skip to content

Commit 2dbdb81

Browse files
committed
Add certifity expiry date check logic
1 parent 5ac815b commit 2dbdb81

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/certapi/manager/acme_cert_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
from typing import List, Literal, Optional, Tuple, Union, Dict
3+
from datetime import datetime, timezone, timedelta
34

45
from certapi import crypto
56
from ..acme import Challenge
@@ -76,8 +77,11 @@ def issue_certificate(
7677
result = self.key_store.find_key_and_cert_by_domain(h)
7778
if result is not None:
7879
# result is (domain_id, key, cert_list)
79-
existing[h] = result # Store the certificate list
80-
80+
cert=result[2][0]
81+
invalid_date = cert.not_valid_after_utc
82+
# Check if the certificate is still valid for at least 30 days
83+
if invalid_date > datetime.now(timezone.utc) + timedelta(days=6):
84+
existing[h] = result
8185
missing = [h for h in hosts if h not in existing]
8286
if len(missing) > 0:
8387
issued_certs_list = []

0 commit comments

Comments
 (0)