ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
evse_security.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
3#ifndef OCPP_COMMON_EVSE_SECURITY
4#define OCPP_COMMON_EVSE_SECURITY
5
6#include <filesystem>
7#include <fstream>
8#include <memory>
9#include <string>
10
11#include <ocpp/common/types.hpp>
12#include <ocpp/v2/ocpp_types.hpp>
13
14namespace ocpp {
15
18
19public:
25 virtual InstallCertificateResult install_ca_certificate(const std::string& certificate,
26 const CaCertificateType& certificate_type) = 0;
27
32 virtual DeleteCertificateResult delete_certificate(const CertificateHashDataType& certificate_hash_data) = 0;
33
41 virtual InstallCertificateResult update_leaf_certificate(const std::string& certificate_chain,
42 const CertificateSigningUseEnum& certificate_type) = 0;
43
49 virtual CertificateValidationResult verify_certificate(const std::string& certificate_chain,
50 const LeafCertificateType& certificate_type) = 0;
51
57 virtual std::vector<CertificateHashDataChain>
58 get_installed_certificates(const std::vector<CertificateType>& certificate_types) = 0;
59
63 virtual std::vector<OCSPRequestData> get_v2g_ocsp_request_data() = 0;
64
69 virtual std::vector<OCSPRequestData> get_mo_ocsp_request_data(const std::string& certificate_chain) = 0;
70
74 virtual void update_ocsp_cache(const CertificateHashDataType& certificate_hash_data,
75 const std::string& ocsp_response) = 0;
76
80 virtual bool is_ca_certificate_installed(const CaCertificateType& certificate_type) = 0;
81
91 generate_certificate_signing_request(const CertificateSigningUseEnum& certificate_type, const std::string& country,
92 const std::string& organization, const std::string& common, bool use_tpm) = 0;
93
102 virtual GetCertificateInfoResult get_leaf_certificate_info(const CertificateSigningUseEnum& certificate_type,
103 bool include_ocsp = false) = 0;
104
106 virtual bool update_certificate_links(const CertificateSigningUseEnum& certificate_type) = 0;
107
111 virtual std::string get_verify_file(const CaCertificateType& certificate_type) = 0;
112
116 virtual std::string get_verify_location(const CaCertificateType& certificate_type) = 0;
117
121 virtual int get_leaf_expiry_days_count(const CertificateSigningUseEnum& certificate_type) = 0;
122};
123
124namespace evse_security_conversions {
125
128ocpp::v2::GetCertificateIdUseEnum to_ocpp_v2(ocpp::CertificateType other);
129ocpp::v2::InstallCertificateUseEnum to_ocpp_v2(ocpp::CaCertificateType other);
130ocpp::v2::HashAlgorithmEnum to_ocpp_v2(ocpp::HashAlgorithmEnumType other);
131ocpp::v2::InstallCertificateStatusEnum to_ocpp_v2(ocpp::InstallCertificateResult other);
132ocpp::v2::DeleteCertificateStatusEnum to_ocpp_v2(ocpp::DeleteCertificateResult other);
133
137std::vector<ocpp::v2::OCSPRequestData> to_ocpp_v2(const std::vector<ocpp::OCSPRequestData>& ocsp_request_data);
138
139ocpp::CertificateType from_ocpp_v2(ocpp::v2::GetCertificateIdUseEnum other);
140std::vector<ocpp::CertificateType> from_ocpp_v2(const std::vector<ocpp::v2::GetCertificateIdUseEnum>& other);
141ocpp::CaCertificateType from_ocpp_v2(ocpp::v2::InstallCertificateUseEnum other);
142ocpp::CertificateSigningUseEnum from_ocpp_v2(ocpp::v2::CertificateSigningUseEnum other);
143ocpp::HashAlgorithmEnumType from_ocpp_v2(ocpp::v2::HashAlgorithmEnum other);
144ocpp::InstallCertificateResult from_ocpp_v2(ocpp::v2::InstallCertificateStatusEnum other);
145ocpp::DeleteCertificateResult from_ocpp_v2(ocpp::v2::DeleteCertificateStatusEnum other);
146
150
151} // namespace evse_security_conversions
152
153} // namespace ocpp
154
155#endif // OCPP_COMMON_EVSE_SECURITY
Handler for security related operations of the charging station.
Definition: evse_security.hpp:17
virtual std::vector< CertificateHashDataChain > get_installed_certificates(const std::vector< CertificateType > &certificate_types)=0
Retrieves all certificates installed on the filesystem applying the certificate_types filter....
virtual GetCertificateSignRequestResult generate_certificate_signing_request(const CertificateSigningUseEnum &certificate_type, const std::string &country, const std::string &organization, const std::string &common, bool use_tpm)=0
Generates a certificate signing request for the given certificate_type , country ,...
virtual std::vector< OCSPRequestData > get_mo_ocsp_request_data(const std::string &certificate_chain)=0
Retrieves the OCSP request data of a certificate chain.
virtual std::vector< OCSPRequestData > get_v2g_ocsp_request_data()=0
Retrieves the OCSP request data of the V2G certificates (exluding the root). This function respects t...
virtual bool update_certificate_links(const CertificateSigningUseEnum &certificate_type)=0
Updates the certificate and key links for the given certificate_type.
virtual int get_leaf_expiry_days_count(const CertificateSigningUseEnum &certificate_type)=0
Gets the expiry day count for the leaf certificate of the given certificate_type.
virtual bool is_ca_certificate_installed(const CaCertificateType &certificate_type)=0
Indicates if a CA certificate for the given certificate_type is installed on the filesystem.
virtual GetCertificateInfoResult get_leaf_certificate_info(const CertificateSigningUseEnum &certificate_type, bool include_ocsp=false)=0
Searches the filesystem on the specified directories for the given certificate_type and retrieves the...
virtual std::string get_verify_file(const CaCertificateType &certificate_type)=0
Retrieves the PEM formatted CA bundle file for the given certificate_type.
virtual void update_ocsp_cache(const CertificateHashDataType &certificate_hash_data, const std::string &ocsp_response)=0
Updates the OCSP cache for the given certificate_hash_data with the given ocsp_response.
virtual DeleteCertificateResult delete_certificate(const CertificateHashDataType &certificate_hash_data)=0
Deletes the certificate specified by certificate_hash_data . This function respects the requirements ...
virtual CertificateValidationResult verify_certificate(const std::string &certificate_chain, const LeafCertificateType &certificate_type)=0
Verifies the given certificate_chain for the given certificate_type against the respective CA certifi...
virtual InstallCertificateResult update_leaf_certificate(const std::string &certificate_chain, const CertificateSigningUseEnum &certificate_type)=0
Verifies the given certificate_chain for the given certificate_type using the respective CA certifica...
virtual InstallCertificateResult install_ca_certificate(const std::string &certificate, const CaCertificateType &certificate_type)=0
Installs the CA certificate for the given certificate_type . This function respects the requirements ...
virtual std::string get_verify_location(const CaCertificateType &certificate_type)=0
Retrieves the PEM formatted CA bundle location for the given certificate_type.
Definition: types.hpp:596
Definition: types.hpp:558
Definition: types.hpp:696
Definition: types.hpp:677
Struct for OCSPRequestData.
Definition: types.hpp:654
Definition: ocpp_types.hpp:271
Definition: ocpp_types.hpp:202
Definition: ocpp_types.hpp:52