From c144d56c7165ef9de1126ae9dacfc4be6ca779b1 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 15 Mar 2024 15:40:53 +0200 Subject: [PATCH] Updated interfaces (#586) * Updated interfaces * Update dependency --------- Signed-off-by: AssemblyJohn --- dependencies.yaml | 2 +- interfaces/evse_security.yaml | 2 +- lib/staging/ocpp/evse_security_ocpp.cpp | 23 ++++++++++++++++++- lib/staging/ocpp/evse_security_ocpp.hpp | 6 +++-- modules/EvseSecurity/conversions.cpp | 21 +++++++++++++++++ modules/EvseSecurity/conversions.hpp | 1 + .../EvseSecurity/main/evse_securityImpl.cpp | 2 +- .../EvseSecurity/main/evse_securityImpl.hpp | 2 +- types/evse_security.yaml | 12 ++++++++++ 9 files changed, 64 insertions(+), 7 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index b49973d52..54aa66164 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -49,7 +49,7 @@ libcurl: # OCPP libocpp: git: https://github.com/EVerest/libocpp.git - git_tag: 10bb269 + git_tag: 86adda6 cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP" # Josev Josev: diff --git a/interfaces/evse_security.yaml b/interfaces/evse_security.yaml index 23842f84e..40feba778 100644 --- a/interfaces/evse_security.yaml +++ b/interfaces/evse_security.yaml @@ -56,7 +56,7 @@ cmds: result: description: Result of the verification type: string - $ref: /evse_security#/InstallCertificateResult + $ref: /evse_security#/CertificateValidationResult get_installed_certificates: description: Command to retrieve installed certificates of the EVSE arguments: diff --git a/lib/staging/ocpp/evse_security_ocpp.cpp b/lib/staging/ocpp/evse_security_ocpp.cpp index c3feb4da5..27fcf5409 100644 --- a/lib/staging/ocpp/evse_security_ocpp.cpp +++ b/lib/staging/ocpp/evse_security_ocpp.cpp @@ -28,7 +28,7 @@ EvseSecurity::update_leaf_certificate(const std::string& certificate_chain, this->r_security.call_update_leaf_certificate(certificate_chain, conversions::from_ocpp(certificate_type))); } -ocpp::InstallCertificateResult +ocpp::CertificateValidationResult EvseSecurity::verify_certificate(const std::string& certificate_chain, const ocpp::CertificateSigningUseEnum& certificate_type) { return conversions::to_ocpp( @@ -194,6 +194,27 @@ ocpp::InstallCertificateResult to_ocpp(types::evse_security::InstallCertificateR } } +ocpp::CertificateValidationResult to_ocpp(types::evse_security::CertificateValidationResult other) { + switch (other) { + case types::evse_security::CertificateValidationResult::Valid: + return ocpp::CertificateValidationResult::Valid; + case types::evse_security::CertificateValidationResult::InvalidSignature: + return ocpp::CertificateValidationResult::InvalidSignature; + case types::evse_security::CertificateValidationResult::IssuerNotFound: + return ocpp::CertificateValidationResult::IssuerNotFound; + case types::evse_security::CertificateValidationResult::InvalidLeafSignature: + return ocpp::CertificateValidationResult::InvalidLeafSignature; + case types::evse_security::CertificateValidationResult::InvalidChain: + return ocpp::CertificateValidationResult::InvalidChain; + case types::evse_security::CertificateValidationResult::Unknown: + return ocpp::CertificateValidationResult::Unknown; + ; + default: + throw std::runtime_error("Could not convert types::evse_security::CertificateValidationResult to " + "ocpp::CertificateValidationResult"); + } +} + ocpp::DeleteCertificateResult to_ocpp(types::evse_security::DeleteCertificateResult other) { switch (other) { case types::evse_security::DeleteCertificateResult::Accepted: diff --git a/lib/staging/ocpp/evse_security_ocpp.hpp b/lib/staging/ocpp/evse_security_ocpp.hpp index 6a14c3168..b1882e6b0 100644 --- a/lib/staging/ocpp/evse_security_ocpp.hpp +++ b/lib/staging/ocpp/evse_security_ocpp.hpp @@ -20,8 +20,9 @@ class EvseSecurity : public ocpp::EvseSecurity { const ocpp::CaCertificateType& certificate_type) override; ocpp::DeleteCertificateResult delete_certificate(const ocpp::CertificateHashDataType& certificate_hash_data) override; - ocpp::InstallCertificateResult verify_certificate(const std::string& certificate_chain, - const ocpp::CertificateSigningUseEnum& certificate_type) override; + ocpp::CertificateValidationResult + verify_certificate(const std::string& certificate_chain, + const ocpp::CertificateSigningUseEnum& certificate_type) override; ocpp::InstallCertificateResult update_leaf_certificate(const std::string& certificate_chain, const ocpp::CertificateSigningUseEnum& certificate_type) override; @@ -47,6 +48,7 @@ ocpp::CertificateSigningUseEnum to_ocpp(types::evse_security::LeafCertificateTyp ocpp::CertificateType to_ocpp(types::evse_security::CertificateType other); ocpp::HashAlgorithmEnumType to_ocpp(types::evse_security::HashAlgorithm other); ocpp::InstallCertificateResult to_ocpp(types::evse_security::InstallCertificateResult other); +ocpp::CertificateValidationResult to_ocpp(types::evse_security::CertificateValidationResult other); ocpp::DeleteCertificateResult to_ocpp(types::evse_security::DeleteCertificateResult other); ocpp::CertificateHashDataType to_ocpp(types::evse_security::CertificateHashData other); diff --git a/modules/EvseSecurity/conversions.cpp b/modules/EvseSecurity/conversions.cpp index 7a58a9fb5..f2417ad7f 100644 --- a/modules/EvseSecurity/conversions.cpp +++ b/modules/EvseSecurity/conversions.cpp @@ -295,6 +295,27 @@ types::evse_security::InstallCertificateResult to_everest(evse_security::Install } } +types::evse_security::CertificateValidationResult to_everest(evse_security::CertificateValidationResult other) { + switch (other) { + case evse_security::CertificateValidationResult::Valid: + return types::evse_security::CertificateValidationResult::Valid; + case evse_security::CertificateValidationResult::InvalidSignature: + return types::evse_security::CertificateValidationResult::InvalidSignature; + case evse_security::CertificateValidationResult::IssuerNotFound: + return types::evse_security::CertificateValidationResult::IssuerNotFound; + case evse_security::CertificateValidationResult::InvalidLeafSignature: + return types::evse_security::CertificateValidationResult::InvalidLeafSignature; + case evse_security::CertificateValidationResult::InvalidChain: + return types::evse_security::CertificateValidationResult::InvalidChain; + case evse_security::CertificateValidationResult::Unknown: + return types::evse_security::CertificateValidationResult::Unknown; + ; + default: + throw std::runtime_error("Could not convert evse_security::CertificateValidationResult to " + "types::evse_security::CertificateValidationResult"); + } +} + types::evse_security::DeleteCertificateResult to_everest(evse_security::DeleteCertificateResult other) { switch (other) { case evse_security::DeleteCertificateResult::Accepted: diff --git a/modules/EvseSecurity/conversions.hpp b/modules/EvseSecurity/conversions.hpp index 700a4b048..b87220a15 100644 --- a/modules/EvseSecurity/conversions.hpp +++ b/modules/EvseSecurity/conversions.hpp @@ -32,6 +32,7 @@ types::evse_security::LeafCertificateType to_everest(evse_security::LeafCertific types::evse_security::CertificateType to_everest(evse_security::CertificateType other); types::evse_security::HashAlgorithm to_everest(evse_security::HashAlgorithm other); types::evse_security::InstallCertificateResult to_everest(evse_security::InstallCertificateResult other); +types::evse_security::CertificateValidationResult to_everest(evse_security::CertificateValidationResult other); types::evse_security::DeleteCertificateResult to_everest(evse_security::DeleteCertificateResult other); types::evse_security::GetInstalledCertificatesStatus to_everest(evse_security::GetInstalledCertificatesStatus other); types::evse_security::GetKeyPairStatus to_everest(evse_security::GetKeyPairStatus other); diff --git a/modules/EvseSecurity/main/evse_securityImpl.cpp b/modules/EvseSecurity/main/evse_securityImpl.cpp index c2a7cb6dd..579a5d98b 100644 --- a/modules/EvseSecurity/main/evse_securityImpl.cpp +++ b/modules/EvseSecurity/main/evse_securityImpl.cpp @@ -45,7 +45,7 @@ evse_securityImpl::handle_update_leaf_certificate(std::string& certificate_chain this->evse_security->update_leaf_certificate(certificate_chain, conversions::from_everest(certificate_type))); } -types::evse_security::InstallCertificateResult +types::evse_security::CertificateValidationResult evse_securityImpl::handle_verify_certificate(std::string& certificate_chain, types::evse_security::LeafCertificateType& certificate_type) { return conversions::to_everest( diff --git a/modules/EvseSecurity/main/evse_securityImpl.hpp b/modules/EvseSecurity/main/evse_securityImpl.hpp index 5de38959b..cccfb15be 100644 --- a/modules/EvseSecurity/main/evse_securityImpl.hpp +++ b/modules/EvseSecurity/main/evse_securityImpl.hpp @@ -42,7 +42,7 @@ class evse_securityImpl : public evse_securityImplBase { virtual types::evse_security::InstallCertificateResult handle_update_leaf_certificate(std::string& certificate_chain, types::evse_security::LeafCertificateType& certificate_type) override; - virtual types::evse_security::InstallCertificateResult + virtual types::evse_security::CertificateValidationResult handle_verify_certificate(std::string& certificate_chain, types::evse_security::LeafCertificateType& certificate_type) override; virtual types::evse_security::GetInstalledCertificatesResult diff --git a/types/evse_security.yaml b/types/evse_security.yaml index 1ab1c6ad6..ad9821e47 100644 --- a/types/evse_security.yaml +++ b/types/evse_security.yaml @@ -50,6 +50,18 @@ types: - CertificateStoreMaxLengthExceeded - WriteError - Accepted + CertificateValidationResult: + description: Result of the attempt to validate a certificate + type: string + enum: + - Valid + - Expired + - InvalidSignature + - IssuerNotFound + - InvalidLeafSignature + - InvalidChain + - Unknown + DeleteCertificateResult: description: Result of the attempt to delete a certificate type: string