Skip to content

Commit

Permalink
fix: add spid_compliant_certificates/validator/checks/time_validity.py
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Jan 25, 2022
1 parent 1fe01bf commit 2cecab0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spid_compliant_certificates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
_min = 4

# micro version
_mic = 0
_mic = 1

# release level (alpha, beta, rc, final)
_rel = 'final'
Expand Down
15 changes: 15 additions & 0 deletions spid_compliant_certificates/validator/checks/time_validity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import datetime

from cryptography import x509
from typing import Any, List, Tuple


def not_expired(cert: x509.Certificate) -> List[Tuple[bool, str, Any]]:
checks = []

msg = f"The Certificate expires in {cert.not_valid_after}"

res = cert.not_valid_after > datetime.datetime.now()
checks.append((res, msg, cert.not_valid_after))

return checks

0 comments on commit 2cecab0

Please sign in to comment.