77import logging
88from time import time
99from typing import Any , List , Union
10+ import os
1011
1112from iso15118 .evcc import evcc_settings
1213from iso15118 .evcc .comm_session_handler import EVCCCommunicationSession
102103)
103104from iso15118 .shared .states import Terminate
104105
106+ from iso15118 .shared .settings import get_PKI_PATH
107+
105108logger = logging .getLogger (__name__ )
106109
107110
@@ -416,10 +419,10 @@ async def process_message(
416419 if await self .comm_session .ev_controller .is_cert_install_needed ():
417420 # TODO: Find a more generic way to serach for all available
418421 # V2GRootCA certificates
419- issuer , serial = get_cert_issuer_serial (CertPath .V2G_ROOT_DER )
422+ issuer , serial = get_cert_issuer_serial (os . path . join ( get_PKI_PATH (), CertPath .V2G_ROOT_DER ) )
420423 cert_install_req = CertificateInstallationReq (
421424 id = "id1" ,
422- oem_provisioning_cert = load_cert (CertPath .OEM_LEAF_DER ),
425+ oem_provisioning_cert = load_cert (os . path . join ( get_PKI_PATH (), CertPath .OEM_LEAF_DER ) ),
423426 list_of_root_cert_ids = RootCertificateIDList (
424427 x509_issuer_serials = [
425428 X509IssuerSerial (
@@ -440,9 +443,9 @@ async def process_message(
440443 )
441444 ],
442445 load_priv_key (
443- KeyPath .OEM_LEAF_PEM ,
446+ os . path . join ( get_PKI_PATH (), KeyPath .OEM_LEAF_PEM ) ,
444447 KeyEncoding .PEM ,
445- KeyPasswordPath .OEM_LEAF_KEY_PASSWORD ,
448+ os . path . join ( get_PKI_PATH (), KeyPasswordPath .OEM_LEAF_KEY_PASSWORD ) ,
446449 ),
447450 )
448451
@@ -462,12 +465,12 @@ async def process_message(
462465 else :
463466 try :
464467 payment_details_req = PaymentDetailsReq (
465- emaid = eMAID (get_cert_cn (load_cert (CertPath .CONTRACT_LEAF_DER ))),
468+ emaid = eMAID (get_cert_cn (load_cert (os . path . join ( get_PKI_PATH (), CertPath .CONTRACT_LEAF_DER ) ))),
466469 cert_chain = load_cert_chain (
467470 protocol = Protocol .ISO_15118_2 ,
468- leaf_path = CertPath .CONTRACT_LEAF_DER ,
469- sub_ca2_path = CertPath .MO_SUB_CA2_DER ,
470- sub_ca1_path = CertPath .MO_SUB_CA1_DER ,
471+ leaf_path = os . path . join ( get_PKI_PATH (), CertPath .CONTRACT_LEAF_DER ) ,
472+ sub_ca2_path = os . path . join ( get_PKI_PATH (), CertPath .MO_SUB_CA2_DER ) ,
473+ sub_ca1_path = os . path . join ( get_PKI_PATH (), CertPath .MO_SUB_CA1_DER ) ,
471474 ),
472475 )
473476 except FileNotFoundError as exc :
@@ -545,7 +548,7 @@ async def process_message(
545548 ],
546549 leaf_cert = cert_install_res .cps_cert_chain .certificate ,
547550 sub_ca_certs = cert_install_res .cps_cert_chain .sub_certificates .certificates ,
548- root_ca_cert = load_cert (CertPath .V2G_ROOT_DER ),
551+ root_ca_cert = load_cert (os . path . join ( get_PKI_PATH (), CertPath .V2G_ROOT_DER ) ),
549552 ):
550553 self .stop_state_machine (
551554 "Signature verification of " "CertificateInstallationRes failed"
@@ -556,9 +559,9 @@ async def process_message(
556559 decrypted_priv_key = decrypt_priv_key (
557560 encrypted_priv_key_with_iv = cert_install_res .encrypted_private_key .value ,
558561 ecdh_priv_key = load_priv_key (
559- KeyPath .OEM_LEAF_PEM ,
562+ os . path . join ( get_PKI_PATH (), KeyPath .OEM_LEAF_PEM ) ,
560563 KeyEncoding .PEM ,
561- KeyPasswordPath .OEM_LEAF_KEY_PASSWORD ,
564+ os . path . join ( get_PKI_PATH (), KeyPasswordPath .OEM_LEAF_KEY_PASSWORD ) ,
562565 ),
563566 ecdh_pub_key = to_ec_pub_key (cert_install_res .dh_public_key .value ),
564567 )
@@ -580,12 +583,12 @@ async def process_message(
580583 return
581584
582585 payment_details_req = PaymentDetailsReq (
583- emaid = get_cert_cn (load_cert (CertPath .CONTRACT_LEAF_DER )),
586+ emaid = get_cert_cn (load_cert (os . path . join ( get_PKI_PATH (), CertPath .CONTRACT_LEAF_DER ) )),
584587 cert_chain = load_cert_chain (
585588 protocol = Protocol .ISO_15118_2 ,
586- leaf_path = CertPath .CONTRACT_LEAF_DER ,
587- sub_ca2_path = CertPath .MO_SUB_CA2_DER ,
588- sub_ca1_path = CertPath .MO_SUB_CA1_DER ,
589+ leaf_path = os . path . join ( get_PKI_PATH (), CertPath .CONTRACT_LEAF_DER ) ,
590+ sub_ca2_path = os . path . join ( get_PKI_PATH (), CertPath .MO_SUB_CA2_DER ) ,
591+ sub_ca1_path = os . path . join ( get_PKI_PATH (), CertPath .MO_SUB_CA1_DER ) ,
589592 ),
590593 )
591594
@@ -636,9 +639,9 @@ async def process_message(
636639 )
637640 ],
638641 load_priv_key (
639- KeyPath .CONTRACT_LEAF_PEM ,
642+ os . path . join ( get_PKI_PATH (), KeyPath .CONTRACT_LEAF_PEM ) ,
640643 KeyEncoding .PEM ,
641- KeyPasswordPath .CONTRACT_LEAF_KEY_PASSWORD ,
644+ os . path . join ( get_PKI_PATH (), KeyPasswordPath .CONTRACT_LEAF_KEY_PASSWORD ) ,
642645 ),
643646 )
644647
@@ -1136,9 +1139,9 @@ async def process_message(
11361139 )
11371140 ],
11381141 load_priv_key (
1139- KeyPath .CONTRACT_LEAF_PEM ,
1142+ os . path . join ( get_PKI_PATH (), KeyPath .CONTRACT_LEAF_PEM ) ,
11401143 KeyEncoding .PEM ,
1141- KeyPasswordPath .CONTRACT_LEAF_KEY_PASSWORD ,
1144+ os . path . join ( get_PKI_PATH (), KeyPasswordPath .CONTRACT_LEAF_KEY_PASSWORD ) ,
11421145 ),
11431146 )
11441147
0 commit comments