Skip to content

Commit

Permalink
Support for tpm CSR request (#381)
Browse files Browse the repository at this point in the history
* Support for tpm CSR request
* Bump libevse-security version to 0.4.0
* Bump libocpp version to 0.9.6

---------

Signed-off-by: AssemblyJohn <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
Co-authored-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
AssemblyJohn and hikinggrass authored Dec 22, 2023
1 parent 7174478 commit 1ecd9cd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)

project(ocpp
VERSION 0.9.5
VERSION 0.9.6
DESCRIPTION "A C++ implementation of the Open Charge Point Protocol"
LANGUAGES CXX
)
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ websocketpp:
git_tag: 0.8.2
libevse-security:
git: https://github.com/EVerest/libevse-security.git
git_tag: v0.3.0
git_tag: v0.4.0
libwebsockets:
git: https://github.com/warmcat/libwebsockets.git
git_tag: v4.3.3
Expand Down
4 changes: 2 additions & 2 deletions include/ocpp/common/evse_security.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class EvseSecurity {
/// \return the PEM formatted certificate signing request
virtual std::string generate_certificate_signing_request(const CertificateSigningUseEnum& certificate_type,
const std::string& country,
const std::string& organization,
const std::string& common) = 0;
const std::string& organization, const std::string& common,
bool use_tpm) = 0;

/// \brief Searches the leaf certificate for the given \p certificate_type and retrieves the most recent certificate
/// that is already valid and the respective key . If no certificate is present or no key is matching the
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/common/evse_security_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EvseSecurityImpl : public EvseSecurity {
bool is_ca_certificate_installed(const CaCertificateType& certificate_type) override;
std::string generate_certificate_signing_request(const CertificateSigningUseEnum& certificate_type,
const std::string& country, const std::string& organization,
const std::string& common) override;
const std::string& common, bool use_tpm) override;
std::optional<KeyPair> get_key_pair(const CertificateSigningUseEnum& certificate_type) override;
std::string get_verify_file(const CaCertificateType& certificate_type) override;
int get_leaf_expiry_days_count(const CertificateSigningUseEnum& certificate_type) override;
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/common/evse_security_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ bool EvseSecurityImpl::is_ca_certificate_installed(const CaCertificateType& cert
std::string EvseSecurityImpl::generate_certificate_signing_request(const CertificateSigningUseEnum& certificate_type,
const std::string& country,
const std::string& organization,
const std::string& common) {
const std::string& common, bool use_tpm) {
return this->evse_security->generate_certificate_signing_request(conversions::from_ocpp(certificate_type), country,
organization, common);
organization, common, use_tpm);
}

std::optional<KeyPair> EvseSecurityImpl::get_key_pair(const CertificateSigningUseEnum& certificate_type) {
Expand Down
6 changes: 4 additions & 2 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,8 @@ void ChargePointImpl::sign_certificate(const ocpp::CertificateSigningUseEnum& ce

const auto csr = this->evse_security->generate_certificate_signing_request(
certificate_signing_use, this->configuration->getSeccLeafSubjectCountry().value_or("DE"),
this->configuration->getCpoName().value(), this->configuration->getChargeBoxSerialNumber());
this->configuration->getCpoName().value(), this->configuration->getChargeBoxSerialNumber(),
this->configuration->getUseTPM());

req.csr = csr;
ocpp::Call<SignCertificateRequest> call(req, this->message_queue->createMessageId());
Expand Down Expand Up @@ -2742,7 +2743,8 @@ void ChargePointImpl::data_transfer_pnc_sign_certificate() {
ocpp::CertificateSigningUseEnum::V2GCertificate,
this->configuration->getSeccLeafSubjectCountry().value_or("DE"),
this->configuration->getSeccLeafSubjectOrganization().value_or(this->configuration->getCpoName().value()),
this->configuration->getSeccLeafSubjectCommonName().value_or(this->configuration->getChargeBoxSerialNumber()));
this->configuration->getSeccLeafSubjectCommonName().value_or(this->configuration->getChargeBoxSerialNumber()),
this->configuration->getUseTPM());

csr_req.csr = csr;
csr_req.certificateType = ocpp::v201::CertificateSigningUseEnum::V2GCertificate;
Expand Down
5 changes: 3 additions & 2 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,9 @@ void ChargePoint::sign_certificate_req(const ocpp::CertificateSigningUseEnum& ce
return;
}

const auto csr = this->evse_security->generate_certificate_signing_request(certificate_signing_use, country.value(),
organization.value(), common.value());
// TODO: use_tpm is hardcoded false here, see if it will require change
const auto csr = this->evse_security->generate_certificate_signing_request(
certificate_signing_use, country.value(), organization.value(), common.value(), false);
req.csr = csr;

this->awaited_certificate_signing_use_enum = certificate_signing_use;
Expand Down

0 comments on commit 1ecd9cd

Please sign in to comment.