Ensure OPENSSL_CONF is a file if it exists

Prevent unexpected behavior in cases where the OPENSSL_CONF path would
exist, but it wouldn't point to a file.
This commit is contained in:
Nicki Křížek 2024-05-06 18:04:46 +02:00
parent ac7c657d19
commit faeec83b64
No known key found for this signature in database
GPG key ID: 01623B9B652A20A7

View file

@ -25,12 +25,13 @@ OPENSSL_VARS = {
def parse_openssl_config(path: Optional[str]):
if path is None or not os.path.isfile(path):
if path is None or not os.path.exists(path):
OPENSSL_VARS["ENGINE_ARG"] = None
OPENSSL_VARS["SOFTHSM2_MODULE"] = None
os.environ.pop("ENGINE_ARG", None)
os.environ.pop("SOFTHSM2_MODULE", None)
return
assert os.path.isfile(path), f"{path} exists, but it's not a file"
regex = re.compile(r"([^=]+)=(.*)")
log.debug(f"parsing openssl config: {path}")