Skip to content

Commit de34b20

Browse files
committed
added option to use an OEM root certificate (this not something standard in ocpp1.6, but will be standard in later ocpp versions to support installing these types of certificates to set up mutual tls with an ev
1 parent 37beb9d commit de34b20

File tree

8 files changed

+53
-15
lines changed

8 files changed

+53
-15
lines changed

examples/common/DefaultChargePointEventsHandler.cpp

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -786,17 +786,20 @@ ocpp::types::DeleteCertificateStatusEnumType DefaultChargePointEventsHandler::is
786786
bool,
787787
bool,
788788
bool,
789+
bool,
789790
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
790791
void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates(
791792
bool v2g_root_certificate,
792793
bool mo_root_certificate,
793794
bool v2g_certificate_chain,
795+
bool oem_root_certificate,
794796
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
795797
certificates)
796798
{
797799
cout << "ISO15118 get installed certificates requested : v2g_root_certificate = " << (v2g_root_certificate ? "yes" : "no")
798800
<< " - mo_root_certificate = " << (mo_root_certificate ? "yes" : "no")
799-
<< " - v2g_certificate_chain = " << (v2g_certificate_chain ? "yes" : "no") << endl;
801+
<< " - v2g_certificate_chain = " << (v2g_certificate_chain ? "yes" : "no")
802+
<< " - oem_root_certificate = " << (oem_root_certificate ? "yes" : "no") << endl;
800803

801804
for (auto const& dir_entry : std::filesystem::directory_iterator{m_working_dir})
802805
{
@@ -833,6 +836,16 @@ void DefaultChargePointEventsHandler::iso15118GetInstalledCertificates(
833836
certificates.emplace_back(std::move(tuple));
834837
}
835838
}
839+
if (oem_root_certificate)
840+
{
841+
if (ocpp::helpers::startsWith(filename, "iso_oem_root_") && ocpp::helpers::endsWith(filename, ".pem"))
842+
{
843+
auto tuple = std::make_tuple(GetCertificateIdUseEnumType::OEMRootCertificate,
844+
Certificate(dir_entry.path()),
845+
std::vector<ocpp::x509::Certificate>());
846+
certificates.emplace_back(std::move(tuple));
847+
}
848+
}
836849
}
837850
}
838851
}
@@ -856,18 +869,23 @@ ocpp::types::InstallCertificateStatusEnumType DefaultChargePointEventsHandler::i
856869
Sha2 sha256;
857870
sha256.compute(certificate.pem().c_str(), certificate.pem().size());
858871

859-
if (type == InstallCertificateUseEnumType::V2GRootCertificate)
860-
{
861-
// V2 root certificate
862-
std::stringstream name;
863-
name << "iso_v2g_root_" << sha256.resultString() << ".pem";
864-
cert_filename = (m_working_dir / name.str()).string();
865-
}
866-
else
867872
{
868-
// MO root certificate
869873
std::stringstream name;
870-
name << "iso_mo_root_" << sha256.resultString() << ".pem";
874+
switch (type)
875+
{
876+
case InstallCertificateUseEnumType::V2GRootCertificate:
877+
name << "iso_v2g_root_";
878+
break;
879+
case InstallCertificateUseEnumType::MORootCertificate:
880+
name << "iso_mo_root_";
881+
break;
882+
case InstallCertificateUseEnumType::OEMRootCertificate:
883+
// Intended fallthrough
884+
default:
885+
name << "iso_oem_root_";
886+
break;
887+
}
888+
name << sha256.resultString() << ".pem";
871889
cert_filename = (m_working_dir / name.str()).string();
872890
}
873891

examples/common/DefaultChargePointEventsHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ class DefaultChargePointEventsHandler : public ocpp::chargepoint::IChargePointEv
186186
bool,
187187
bool,
188188
bool,
189+
bool,
189190
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
190191
void iso15118GetInstalledCertificates(
191192
bool v2g_root_certificate,
192193
bool mo_root_certificate,
193194
bool v2g_certificate_chain,
195+
bool oem_root_certificate,
194196
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
195197
certificates) override;
196198

src/chargepoint/interface/IChargePointEventsHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,14 @@ class IChargePointEventsHandler
324324
* @param v2g_root_certificate Indicate if V2G root certificates must be listed
325325
* @param mo_root_certificate Indicate if MO root certificates must be listed
326326
* @param v2g_certificate_chain Indicate if V2G certificate chains must be listed
327+
* @param oem_root_certificate Indicate if OEM root certificates must be listed
327328
* @param certificates Installed certificates with their type
328329
*/
329330
virtual void iso15118GetInstalledCertificates(
330331
bool v2g_root_certificate,
331332
bool mo_root_certificate,
332333
bool v2g_certificate_chain,
334+
bool oem_root_certificate,
333335
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
334336
certificates) = 0;
335337

src/chargepoint/iso15118/Iso15118Manager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,14 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica
339339
bool v2g_root_certificate = false;
340340
bool mo_root_certificate = false;
341341
bool v2g_certificate_chain = false;
342+
bool oem_root_certificate = false;
342343
if (request.certificateType.empty())
343344
{
344345
// All types requested
345346
v2g_root_certificate = true;
346347
mo_root_certificate = true;
347348
v2g_certificate_chain = true;
349+
oem_root_certificate = true;
348350
}
349351
else
350352
{
@@ -359,6 +361,9 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica
359361
case GetCertificateIdUseEnumType::MORootCertificate:
360362
mo_root_certificate = true;
361363
break;
364+
case GetCertificateIdUseEnumType::OEMRootCertificate:
365+
oem_root_certificate = true;
366+
break;
362367
case GetCertificateIdUseEnumType::V2GCertificateChain:
363368
// Intended fallthrough
364369
default:
@@ -370,7 +375,7 @@ void Iso15118Manager::handle(const ocpp::messages::Iso15118GetInstalledCertifica
370375

371376
// Notify handler to get the list of installed certificates
372377
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>> certificates;
373-
m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, certificates);
378+
m_events_handler.iso15118GetInstalledCertificates(v2g_root_certificate, mo_root_certificate, v2g_certificate_chain, oem_root_certificate, certificates);
374379
if (!certificates.empty())
375380
{
376381
// Compute hashes for each certificate

src/types/Enums.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,9 @@ enum class GetCertificateIdUseEnumType
10251025
their certificates from the V2G root */
10261026
MORootCertificate,
10271027
/** @brief ISO 15118 V2G certificate chain (excluding the V2GRootCertificate) */
1028-
V2GCertificateChain
1028+
V2GCertificateChain,
1029+
/** @brief ISO 15118-20 OEM root certificates */
1030+
OEMRootCertificate
10291031
};
10301032

10311033
/** @brief Helper to convert a GetCertificateIdUseEnumType enum to string */
@@ -1064,7 +1066,9 @@ enum class InstallCertificateUseEnumType
10641066
certificates */
10651067
V2GRootCertificate,
10661068
/** @brief Use for certificate from an eMobility Service */
1067-
MORootCertificate
1069+
MORootCertificate,
1070+
/** @brief Use for certificate from an OEM (Vehicle Manufacturer used for bi-directional TLS connection between Secc and EV */
1071+
OEMRootCertificate
10681072
};
10691073

10701074
/** @brief Helper to convert a InstallCertificateUseEnumType enum to string */

tests/deploy/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,12 +923,14 @@ class ChargePointEventsHandler : public IChargePointEventsHandler
923923
bool v2g_root_certificate,
924924
bool mo_root_certificate,
925925
bool v2g_certificate_chain,
926+
bool oem_root_certificate,
926927
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
927928
certificates) override
928929
{
929930
(void)v2g_root_certificate;
930931
(void)mo_root_certificate;
931932
(void)v2g_certificate_chain;
933+
(void)oem_root_certificate;
932934
(void)certificates;
933935
}
934936

tests/stubs/ChargePointEventsHandlerStub.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,21 @@ ocpp::types::DeleteCertificateStatusEnumType ChargePointEventsHandlerStub::iso15
339339
bool,
340340
bool,
341341
bool,
342+
bool,
342343
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
343344
void ChargePointEventsHandlerStub::iso15118GetInstalledCertificates(
344345
bool v2g_root_certificate,
345346
bool mo_root_certificate,
346347
bool v2g_certificate_chain,
348+
bool oem_root_certificate,
347349
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
348350
certificates)
349351
{
350352
(void)certificates;
351353
m_calls["iso15118GetInstalledCertificates"] = {{"v2g_root_certificate", std::to_string(v2g_root_certificate)},
352354
{"mo_root_certificate", std::to_string(mo_root_certificate)},
353-
{"v2g_certificate_chain", std::to_string(v2g_certificate_chain)}};
355+
{"v2g_certificate_chain", std::to_string(v2g_certificate_chain)},
356+
{"oem_root_certificate", std::to_string(oem_root_certificate)}};
354357
}
355358

356359
/** @copydoc ocpp::types::InstallCertificateStatusEnumType IChargePointEventsHandler::iso15118CertificateReceived(

tests/stubs/ChargePointEventsHandlerStub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ class ChargePointEventsHandlerStub : public ocpp::chargepoint::IChargePointEvent
173173
bool,
174174
bool,
175175
bool,
176+
bool,
176177
std::vector<std::tuple<GetCertificateIdUseEnumType, Certificate, std::vector<Certificate>>>&) */
177178
void iso15118GetInstalledCertificates(
178179
bool v2g_root_certificate,
179180
bool mo_root_certificate,
180181
bool v2g_certificate_chain,
182+
bool oem_root_certificate,
181183
std::vector<std::tuple<ocpp::types::GetCertificateIdUseEnumType, ocpp::x509::Certificate, std::vector<ocpp::x509::Certificate>>>&
182184
certificates) override;
183185

0 commit comments

Comments
 (0)