diff --git a/iso15118/shared/security.py b/iso15118/shared/security.py index 25436935..109d9b60 100644 --- a/iso15118/shared/security.py +++ b/iso15118/shared/security.py @@ -164,7 +164,7 @@ def get_ssl_context(server_side: bool) -> Optional[SSLContext]: # pymongo setup a client side, but we also need the server side: # https://github.com/pyca/pyopenssl/blob/main/src/OpenSSL/SSL.py#L1653 - if SettingKey.FORCE_TLS_CLIENT_AUTH: + if shared_settings[SettingKey.FORCE_TLS_CLIENT_AUTH]: # In 15118-20 we should also verify EVCC's certificate chain. # The spec however says TLS 1.3 should also support 15118-2 # (Table 5 in V2G20 specification) @@ -225,7 +225,7 @@ def get_ssl_context(server_side: bool) -> Optional[SSLContext]: "ECDHE-ECDSA-AES128-SHA256" ) - if SettingKey.FORCE_TLS_CLIENT_AUTH: + if shared_settings[SettingKey.FORCE_TLS_CLIENT_AUTH]: logger.debug("LOADING CERTIFICATES OEM") try: ssl_context.load_cert_chain( @@ -259,7 +259,7 @@ def get_ssl_context(server_side: bool) -> Optional[SSLContext]: # https://docs.python.org/3/library/ssl.html#ssl.create_default_context # https://docs.python.org/3/library/ssl.html#ssl.SSLContext.keylog_filename # https://github.com/python/cpython/blob/3.11/Lib/ssl.py#L777 - keylogfile = os.path.join(SettingKey.PKI_PATH, "keylogfile.txt") + keylogfile = os.path.join(shared_settings[SettingKey.PKI_PATH], "keylogfile.txt") if logging.getLogger().level == logging.DEBUG: if not os.path.exists(keylogfile): with open(keylogfile, 'w'): diff --git a/iso15118/shared/settings.py b/iso15118/shared/settings.py index 31794d81..8fa6e367 100644 --- a/iso15118/shared/settings.py +++ b/iso15118/shared/settings.py @@ -8,7 +8,7 @@ class SettingKey: PKI_PATH = "PKI_PATH" MESSAGE_LOG_JSON = "MESSAGE_LOG_JSON" MESSAGE_LOG_EXI = "MESSAGE_LOG_EXI" - ENABLE_TLS_1_3 = "ENABLE_TLS_1_3" + FORCE_TLS_CLIENT_AUTH = "FORCE_TLS_CLIENT_AUTH" shared_settings = {} @@ -27,7 +27,6 @@ def load_shared_settings(env_path: Optional[str] = None): SettingKey.MESSAGE_LOG_JSON: env.bool("MESSAGE_LOG_JSON", default=True), SettingKey.MESSAGE_LOG_EXI: env.bool("MESSAGE_LOG_EXI", default=False), SettingKey.FORCE_TLS_CLIENT_AUTH: env.bool("FORCE_TLS_CLIENT_AUTH", default=False), - SettingKey.ENABLE_TLS_1_3: env.bool("ENABLE_TLS_1_3", default=False), } shared_settings.update(settings) env.seal() # raise all errors at once, if any