diff --git a/examples/common/DefaultChargePointEventsHandler.cpp b/examples/common/DefaultChargePointEventsHandler.cpp index 369039b0..fd6e1e8d 100644 --- a/examples/common/DefaultChargePointEventsHandler.cpp +++ b/examples/common/DefaultChargePointEventsHandler.cpp @@ -786,17 +786,20 @@ ocpp::types::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::is bool, bool, bool, + bool, std::vector>>&) */ void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates( bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) { cout << "ISO15118 get installed certificates requested : v2g_root_certificate = " << (v2g_root_certificate ? "yes" : "no") << " - mo_root_certificate = " << (mo_root_certificate ? "yes" : "no") - << " - v2g_certificate_chain = " << (v2g_certificate_chain ? "yes" : "no") << endl; + << " - v2g_certificate_chain = " << (v2g_certificate_chain ? "yes" : "no") + << " - oem_root_certificate = " << (oem_root_certificate ? "yes" : "no") << endl; for (auto const& dir_entry : std::filesystem::directory_iterator{m_working_dir}) { @@ -833,6 +836,16 @@ void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates( certificates.emplace_back(std::move(tuple)); } } + if (oem_root_certificate) + { + if (ocpp::helpers::startsWith(filename, "iso_oem_root_") && ocpp::helpers::endsWith(filename, ".pem")) + { + auto tuple = std::make_tuple(GetCertificateIdUseEnumType::OEMRootCertificate, + Certificate(dir_entry.path()), + std::vector()); + certificates.emplace_back(std::move(tuple)); + } + } } } } @@ -856,18 +869,23 @@ ocpp::types::InstallCertificateStatusEnumType DefaultChargePointEventsHandler::i Sha2 sha256; sha256.compute(certificate.pem().c_str(), certificate.pem().size()); - if (type == InstallCertificateUseEnumType::V2GRootCertificate) - { - // V2 root certificate - std::stringstream name; - name << "iso_v2g_root_" << sha256.resultString() << ".pem"; - cert_filename = (m_working_dir / name.str()).string(); - } - else { - // MO root certificate std::stringstream name; - name << "iso_mo_root_" << sha256.resultString() << ".pem"; + switch (type) + { + case InstallCertificateUseEnumType::V2GRootCertificate: + name << "iso_v2g_root_"; + break; + case InstallCertificateUseEnumType::MORootCertificate: + name << "iso_mo_root_"; + break; + case InstallCertificateUseEnumType::OEMRootCertificate: + // Intended fallthrough + default: + name << "iso_oem_root_"; + break; + } + name << sha256.resultString() << ".pem"; cert_filename = (m_working_dir / name.str()).string(); } diff --git a/examples/common/DefaultChargePointEventsHandler.h b/examples/common/DefaultChargePointEventsHandler.h index cc23c18d..6e40d6cf 100644 --- a/examples/common/DefaultChargePointEventsHandler.h +++ b/examples/common/DefaultChargePointEventsHandler.h @@ -186,11 +186,13 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv bool, bool, bool, + bool, std::vector>>&) */ void iso15118GetInstalledCertificates( bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) override; diff --git a/src/chargepoint/interface/IChargePointEventsHandler.h b/src/chargepoint/interface/IChargePointEventsHandler.h index f8faed84..e8b22e25 100644 --- a/src/chargepoint/interface/IChargePointEventsHandler.h +++ b/src/chargepoint/interface/IChargePointEventsHandler.h @@ -324,12 +324,14 @@ class IChargePointEventsHandler * @param v2g_root_certificate Indicate if V2G root certificates must be listed * @param mo_root_certificate Indicate if MO root certificates must be listed * @param v2g_certificate_chain Indicate if V2G certificate chains must be listed + * @param oem_root_certificate Indicate if OEM root certificates must be listed * @param certificates Installed certificates with their type */ virtual void iso15118GetInstalledCertificates( bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) = 0; diff --git a/src/chargepoint/iso15118/Iso15118Manager.cpp b/src/chargepoint/iso15118/Iso15118Manager.cpp index 923fd620..14aeb522 100644 --- a/src/chargepoint/iso15118/Iso15118Manager.cpp +++ b/src/chargepoint/iso15118/Iso15118Manager.cpp @@ -339,12 +339,14 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica bool v2g_root_certificate = false; bool mo_root_certificate = false; bool v2g_certificate_chain = false; + bool oem_root_certificate = false; if (request.certificateType.empty()) { // All types requested v2g_root_certificate = true; mo_root_certificate = true; v2g_certificate_chain = true; + oem_root_certificate = true; } else { @@ -359,6 +361,9 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica case GetCertificateIdUseEnumType::MORootCertificate: mo_root_certificate = true; break; + case GetCertificateIdUseEnumType::OEMRootCertificate: + oem_root_certificate = true; + break; case GetCertificateIdUseEnumType::V2GCertificateChain: // Intended fallthrough default: @@ -370,7 +375,7 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica // Notify handler to get the list of installed certificates std::vector>> certificates; - m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, certificates); + m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates); if (!certificates.empty()) { // Compute hashes for each certificate diff --git a/src/messages/Iso15118InstallCertificate.cpp b/src/messages/Iso15118InstallCertificate.cpp index a483fee8..38579306 100644 --- a/src/messages/Iso15118InstallCertificate.cpp +++ b/src/messages/Iso15118InstallCertificate.cpp @@ -29,7 +29,8 @@ namespace types /** @brief Helper to convert a enum class InstallCertificateUseEnumType enum to string */ const EnumToStringFromString InstallCertificateUseEnumTypeHelper = { {InstallCertificateUseEnumType::MORootCertificate, "MORootCertificate"}, - {InstallCertificateUseEnumType::V2GRootCertificate, "V2GRootCertificate"}}; + {InstallCertificateUseEnumType::V2GRootCertificate, "V2GRootCertificate"}, + {InstallCertificateUseEnumType::OEMRootCertificate, "OEMRootCertificate"}}; /** @brief Helper to convert a enum class InstallCertificateStatusEnumType enum to string */ const EnumToStringFromString InstallCertificateStatusEnumTypeHelper = { diff --git a/src/messages/types/CertificateHashDataChainTypeConverter.cpp b/src/messages/types/CertificateHashDataChainTypeConverter.cpp index 10d7f5fb..4fd98cb3 100644 --- a/src/messages/types/CertificateHashDataChainTypeConverter.cpp +++ b/src/messages/types/CertificateHashDataChainTypeConverter.cpp @@ -32,8 +32,8 @@ namespace types const EnumToStringFromString GetCertificateIdUseEnumTypeHelper = { {GetCertificateIdUseEnumType::MORootCertificate, "MORootCertificate"}, {GetCertificateIdUseEnumType::V2GCertificateChain, "V2GCertificateChain"}, - {GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"}}; - + {GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"}, + {GetCertificateIdUseEnumType::OEMRootCertificate, "OEMRootCertificate"}}; } // namespace types namespace messages diff --git a/src/types/Enums.h b/src/types/Enums.h index 815ec2c9..c67bc70e 100644 --- a/src/types/Enums.h +++ b/src/types/Enums.h @@ -1025,7 +1025,9 @@ enum class GetCertificateIdUseEnumType their certificates from the V2G root */ MORootCertificate, /** @brief ISO 15118 V2G certificate chain (excluding the V2GRootCertificate) */ - V2GCertificateChain + V2GCertificateChain, + /** @brief ISO 15118-20 OEM root certificates */ + OEMRootCertificate }; /** @brief Helper to convert a GetCertificateIdUseEnumType enum to string */ @@ -1064,7 +1066,9 @@ enum class InstallCertificateUseEnumType certificates */ V2GRootCertificate, /** @brief Use for certificate from an eMobility Service */ - MORootCertificate + MORootCertificate, + /** @brief Use for certificate from an OEM (Vehicle Manufacturer used for bi-directional TLS connection between Secc and EV */ + OEMRootCertificate }; /** @brief Helper to convert a InstallCertificateUseEnumType enum to string */ diff --git a/tests/deploy/main.cpp b/tests/deploy/main.cpp index 529eda5d..40df9f6b 100644 --- a/tests/deploy/main.cpp +++ b/tests/deploy/main.cpp @@ -923,12 +923,14 @@ class ChargePointEventsHandler : public IChargePointEventsHandler bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) override { (void)v2g_root_certificate; (void)mo_root_certificate; (void)v2g_certificate_chain; + (void)oem_root_certificate; (void)certificates; } diff --git a/tests/stubs/ChargePointEventsHandlerStub.cpp b/tests/stubs/ChargePointEventsHandlerStub.cpp index ce30bedf..64e88762 100755 --- a/tests/stubs/ChargePointEventsHandlerStub.cpp +++ b/tests/stubs/ChargePointEventsHandlerStub.cpp @@ -339,18 +339,21 @@ ocpp::types::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::iso15 bool, bool, bool, + bool, std::vector>>&) */ void ChargePointEventsHandlerStub::iso15118GetInstalledCertificates( bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) { (void)certificates; m_calls["iso15118GetInstalledCertificates"] = {{"v2g_root_certificate", std::to_string(v2g_root_certificate)}, {"mo_root_certificate", std::to_string(mo_root_certificate)}, - {"v2g_certificate_chain", std::to_string(v2g_certificate_chain)}}; + {"v2g_certificate_chain", std::to_string(v2g_certificate_chain)}, + {"oem_root_certificate", std::to_string(oem_root_certificate)}}; } /** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived( diff --git a/tests/stubs/ChargePointEventsHandlerStub.h b/tests/stubs/ChargePointEventsHandlerStub.h index 5f9754da..f173d85d 100755 --- a/tests/stubs/ChargePointEventsHandlerStub.h +++ b/tests/stubs/ChargePointEventsHandlerStub.h @@ -173,11 +173,13 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent bool, bool, bool, + bool, std::vector>>&) */ void iso15118GetInstalledCertificates( bool v2g_root_certificate, bool mo_root_certificate, bool v2g_certificate_chain, + bool oem_root_certificate, std::vector>>& certificates) override;