Merge commit '8c53cd751261a9c46177fd509aa49d591dd4bcf2'
This commit is contained in:
@@ -35,6 +35,9 @@ import sys
|
||||
sys.path.append(".")
|
||||
sys.path.append("..")
|
||||
|
||||
# System-level activities:
|
||||
import io
|
||||
|
||||
# To check certs through cryptographic algorithms:
|
||||
from cryptography import x509
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
@@ -204,7 +207,7 @@ class CertExpiryCheck:
|
||||
# ┃ ┏┓┏┏┓┃ ┃ ┏┓┏┓╋┏
|
||||
# ┗┛┗┛┗┗┻┗ ┗┛┗ ┛ ┗┛
|
||||
|
||||
def load_local(self, path: str) -> bool:
|
||||
def load_local(self, path: str | io.BytesIO) -> bool:
|
||||
|
||||
"""
|
||||
Loads a certificate stored on a local file path and checks for its validity.
|
||||
@@ -221,8 +224,13 @@ class CertExpiryCheck:
|
||||
try:
|
||||
|
||||
# Read the contents of the certificate file:
|
||||
with open(path, 'rb') as f:
|
||||
cert_data = f.read()
|
||||
if isinstance(path, str):
|
||||
with open(path, 'rb') as f:
|
||||
cert_data = f.read()
|
||||
elif isinstance(path, io.BytesIO):
|
||||
path.seek(0)
|
||||
cert_data = path.read()
|
||||
else: cert_data = None
|
||||
|
||||
# Load the certificate:
|
||||
cert = x509.load_pem_x509_certificate(cert_data, default_backend())
|
||||
|
||||
Reference in New Issue
Block a user