Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions examples/common/DefaultChargePointEventsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,17 +786,20 @@ ocpp::types::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::is
bool,
bool,
bool,
bool,
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates(
bool v2g_root_certificate,
bool mo_root_certificate,
bool v2g_certificate_chain,
bool oem_root_certificate,
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
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})
{
Expand Down Expand Up @@ -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<ocpp::x509::Certificate>());
certificates.emplace_back(std::move(tuple));
}
}
}
}
}
Expand All @@ -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();
}

Expand Down
2 changes: 2 additions & 0 deletions examples/common/DefaultChargePointEventsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv
bool,
bool,
bool,
bool,
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
void iso15118GetInstalledCertificates(
bool v2g_root_certificate,
bool mo_root_certificate,
bool v2g_certificate_chain,
bool oem_root_certificate,
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
certificates) override;

Expand Down
2 changes: 2 additions & 0 deletions src/chargepoint/interface/IChargePointEventsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
certificates) = 0;

Expand Down
7 changes: 6 additions & 1 deletion src/chargepoint/iso15118/Iso15118Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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:
Expand All @@ -370,7 +375,7 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica

// Notify handler to get the list of installed certificates
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>> 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
Expand Down
3 changes: 2 additions & 1 deletion src/messages/Iso15118InstallCertificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace types
/** @brief Helper to convert a enum class InstallCertificateUseEnumType enum to string */
const EnumToStringFromString<InstallCertificateUseEnumType> 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<InstallCertificateStatusEnumType> InstallCertificateStatusEnumTypeHelper = {
Expand Down
4 changes: 2 additions & 2 deletions src/messages/types/CertificateHashDataChainTypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace types
const EnumToStringFromString<GetCertificateIdUseEnumType> GetCertificateIdUseEnumTypeHelper = {
{GetCertificateIdUseEnumType::MORootCertificate, "MORootCertificate"},
{GetCertificateIdUseEnumType::V2GCertificateChain, "V2GCertificateChain"},
{GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"}};

{GetCertificateIdUseEnumType::V2GRootCertificate, "V2GRootCertificate"},
{GetCertificateIdUseEnumType::OEMRootCertificate, "OEMRootCertificate"}};
} // namespace types

namespace messages
Expand Down
8 changes: 6 additions & 2 deletions src/types/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions tests/deploy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
certificates) override
{
(void)v2g_root_certificate;
(void)mo_root_certificate;
(void)v2g_certificate_chain;
(void)oem_root_certificate;
(void)certificates;
}

Expand Down
5 changes: 4 additions & 1 deletion tests/stubs/ChargePointEventsHandlerStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,21 @@ ocpp::types::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::iso15
bool,
bool,
bool,
bool,
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
void ChargePointEventsHandlerStub::iso15118GetInstalledCertificates(
bool v2g_root_certificate,
bool mo_root_certificate,
bool v2g_certificate_chain,
bool oem_root_certificate,
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
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(
Expand Down
2 changes: 2 additions & 0 deletions tests/stubs/ChargePointEventsHandlerStub.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,13 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent
bool,
bool,
bool,
bool,
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
void iso15118GetInstalledCertificates(
bool v2g_root_certificate,
bool mo_root_certificate,
bool v2g_certificate_chain,
bool oem_root_certificate,
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
certificates) override;

Expand Down
Loading