Skip to content

Commit 50594a5

Browse files
authored
EVerest Plug'n Charge Integration: (#4)
- Adapted to iso15118_charger PnC extension - Added CertificateUpdate state PKI_Handler: - Adjusted create_certs script and changed cert names - Added ocsp info to cpoSubCas - Changed the organizationName and countryName from all pki config files to EVerest and DE Signed-off-by: Sebastian Lukas <sebastian.lukas@pionix.de> Signed-off-by: pietfried <piet.goempel@pionix.de>
1 parent 174ecc8 commit 50594a5

24 files changed

Lines changed: 550 additions & 473 deletions

iso15118/evcc/states/iso15118_20_states.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
import time
99
from typing import Any, List, Union
10+
import os
1011

1112
from iso15118.evcc.comm_session_handler import EVCCCommunicationSession
1213
from iso15118.evcc.states.evcc_state import StateEVCC
@@ -86,6 +87,7 @@
8687
load_priv_key,
8788
)
8889
from iso15118.shared.states import Terminate
90+
from iso15118.shared.settings import get_PKI_PATH
8991

9092
logger = logging.getLogger(__name__)
9193

@@ -174,13 +176,13 @@ async def process_message(
174176
):
175177
# TODO: Find a more generic way to search for all available
176178
# V2GRootCA certificates
177-
issuer, serial = get_cert_issuer_serial(CertPath.V2G_ROOT_DER)
179+
issuer, serial = get_cert_issuer_serial(os.path.join(get_PKI_PATH(), CertPath.V2G_ROOT_DER))
178180

179181
oem_prov_cert_chain = load_cert_chain(
180182
protocol=self.comm_session.protocol,
181-
leaf_path=CertPath.OEM_LEAF_DER,
182-
sub_ca2_path=CertPath.OEM_SUB_CA2_DER,
183-
sub_ca1_path=CertPath.OEM_SUB_CA1_DER,
183+
leaf_path=os.path.join(get_PKI_PATH(), CertPath.OEM_LEAF_DER),
184+
sub_ca2_path=os.path.join(get_PKI_PATH(), CertPath.OEM_SUB_CA2_DER),
185+
sub_ca1_path=os.path.join(get_PKI_PATH(), CertPath.OEM_SUB_CA1_DER),
184186
id="id1",
185187
)
186188

@@ -197,9 +199,9 @@ async def process_message(
197199
)
198200
],
199201
load_priv_key(
200-
KeyPath.OEM_LEAF_PEM,
202+
os.path.join(get_PKI_PATH(), KeyPath.OEM_LEAF_PEM),
201203
KeyEncoding.PEM,
202-
KeyPasswordPath.OEM_LEAF_KEY_PASSWORD,
204+
os.path.join(get_PKI_PATH(), KeyPasswordPath.OEM_LEAF_KEY_PASSWORD),
203205
),
204206
)
205207

@@ -244,9 +246,9 @@ async def process_message(
244246
gen_challenge=auth_setup_res.pnc_as_res.gen_challenge,
245247
contract_cert_chain=load_cert_chain(
246248
protocol=self.comm_session.protocol,
247-
leaf_path=CertPath.CONTRACT_LEAF_DER,
248-
sub_ca2_path=CertPath.MO_SUB_CA2_DER,
249-
sub_ca1_path=CertPath.MO_SUB_CA1_DER,
249+
leaf_path=os.path.join(get_PKI_PATH(), CertPath.CONTRACT_LEAF_DER),
250+
sub_ca2_path=os.path.join(get_PKI_PATH(), CertPath.MO_SUB_CA2_DER),
251+
sub_ca1_path=os.path.join(get_PKI_PATH(), CertPath.MO_SUB_CA1_DER),
250252
),
251253
id="id1",
252254
)
@@ -260,9 +262,9 @@ async def process_message(
260262
try:
261263
# The private key to be used for the signature
262264
signature_key = load_priv_key(
263-
KeyPath.CONTRACT_LEAF_PEM,
265+
os.path.join(get_PKI_PATH(), KeyPath.CONTRACT_LEAF_PEM),
264266
KeyEncoding.PEM,
265-
KeyPasswordPath.CONTRACT_LEAF_KEY_PASSWORD,
267+
os.path.join(get_PKI_PATH(), KeyPasswordPath.CONTRACT_LEAF_KEY_PASSWORD),
266268
)
267269
signature = create_signature(elements_to_sign, signature_key)
268270
except PrivateKeyReadError as exc:

iso15118/evcc/states/iso15118_2_states.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
from time import time
99
from typing import Any, List, Union
10+
import os
1011

1112
from iso15118.evcc import evcc_settings
1213
from iso15118.evcc.comm_session_handler import EVCCCommunicationSession
@@ -102,6 +103,8 @@
102103
)
103104
from iso15118.shared.states import Terminate
104105

106+
from iso15118.shared.settings import get_PKI_PATH
107+
105108
logger = 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

Comments
 (0)