Skip to content

Commit

Permalink
Added config possibility for v201
Browse files Browse the repository at this point in the history
Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn committed Mar 6, 2024
1 parent cddd1a3 commit e4ec1e9
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 13 deletions.
4 changes: 2 additions & 2 deletions config/v16/profile_schemas/Internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@
"VerifyCsmsCommonName": {
"$comment": "Verify that the CSMS certificates commonName matches the CSMS FQDN",
"type": "boolean",
"readOnly": true,
"readOnly": false,
"default": true
},
"VerifyCsmsAllowWildcards": {
"$comment": "Allow wildcards when verifying the CSMS commonName",
"type": "boolean",
"readOnly": true,
"readOnly": false,
"default": false
},
"OcspRequestInterval": {
Expand Down
45 changes: 45 additions & 0 deletions config/v201/component_schemas/standardized/InternalCtrlr.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,51 @@
"default": true,
"type": "boolean"
},
"VerifyCsmsCommonName": {
"variable_name": "VerifyCsmsCommonName",
"characteristics": {
"supportsMonitoring": false,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"default": true,
"type": "boolean"
},
"UseTPM": {
"variable_name": "UseTPM",
"characteristics": {
"supportsMonitoring": false,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"default": false,
"type": "boolean"
},
"VerifyCsmsAllowWildcards": {
"variable_name": "VerifyCsmsAllowWildcards",
"characteristics": {
"supportsMonitoring": false,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadWrite"
}
],
"default": false,
"type": "boolean"
},
"OcspRequestInterval": {
"variable_name": "OcspRequestInterval",
"characteristics": {
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v16/charge_point_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ChargePointConfiguration {
bool getVerifyCsmsCommonName();
KeyValue getVerifyCsmsCommonNameKeyValue();
bool getVerifyCsmsAllowWildcards();
KeyValue getVerifyCsmsAllowWildcardsKeyValue();
bool getUseTPM();
std::string getSupportedMeasurands();
KeyValue getSupportedMeasurandsKeyValue();
Expand Down
3 changes: 3 additions & 0 deletions include/ocpp/v201/ctrlr_component_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ extern const ComponentVariable& RoundClockAlignedTimestamps;
extern const ComponentVariable& MaxCompositeScheduleDuration;
extern const RequiredComponentVariable& NumberOfConnectors;
extern const ComponentVariable& UseSslDefaultVerifyPaths;
extern const ComponentVariable& VerifyCsmsCommonName;
extern const ComponentVariable& UseTPM;
extern const ComponentVariable& VerifyCsmsAllowWildcards;
extern const ComponentVariable& OcspRequestInterval;
extern const ComponentVariable& WebsocketPingPayload;
extern const ComponentVariable& WebsocketPongTimeout;
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/common/websocket/websocket_tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ tls_context WebsocketTLS::on_tls_init(std::string hostname, websocketpp::connect
if (this->connection_options.verify_csms_common_name) {

// Verify hostname
X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
X509_VERIFY_PARAM* param = X509_VERIFY_PARAM_new();

if(this->connection_options.verify_csms_allow_wildcards) {
if (this->connection_options.verify_csms_allow_wildcards) {
X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
} else {
X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_WILDCARDS);
Expand Down
12 changes: 11 additions & 1 deletion lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ bool ChargePointConfiguration::getVerifyCsmsAllowWildcards() {
return this->config["Internal"]["VerifyCsmsAllowWildcards"];
}


std::string ChargePointConfiguration::getSupportedMeasurands() {
return this->config["Internal"]["SupportedMeasurands"];
}
Expand Down Expand Up @@ -550,6 +549,14 @@ KeyValue ChargePointConfiguration::getVerifyCsmsCommonNameKeyValue() {
return kv;
}

KeyValue ChargePointConfiguration::getVerifyCsmsAllowWildcardsKeyValue() {
KeyValue kv;
kv.key = "VerifyCsmsAllowWildcards";
kv.readonly = true;
kv.value.emplace(ocpp::conversions::bool_to_string(this->getVerifyCsmsAllowWildcards()));
return kv;
}

KeyValue ChargePointConfiguration::getSupportedMeasurandsKeyValue() {
KeyValue kv;
kv.key = "SupportedMeasurands";
Expand Down Expand Up @@ -2256,6 +2263,9 @@ std::optional<KeyValue> ChargePointConfiguration::get(CiString<50> key) {
if (key == "VerifyCsmsCommonName") {
return this->getVerifyCsmsCommonNameKeyValue();
}
if (key == "VerifyCsmsAllowWildcards") {
return this->getVerifyCsmsAllowWildcardsKeyValue();
}
if (key == "OcspRequestInterval") {
return this->getOcspRequestIntervalKeyValue();
}
Expand Down
3 changes: 1 addition & 2 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ WebsocketConnectionOptions ChargePointImpl::get_ws_connection_options() {
this->configuration->getHostName(),
this->configuration->getVerifyCsmsCommonName(),
this->configuration->getUseTPM(),
this->configuration->getVerifyCsmsAllowWildcards()
};
this->configuration->getVerifyCsmsAllowWildcards()};
return connection_options;
}

Expand Down
14 changes: 8 additions & 6 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,10 @@ WebsocketConnectionOptions ChargePoint::get_ws_connection_options(const int32_t
this->device_model->get_optional_value<bool>(ControllerComponentVariables::AdditionalRootCertificateCheck)
.value_or(false),
std::nullopt, // hostName
true, // verify_csms_common_name
false, // use tpm
false // verify_csms_allow_wildcards
};
this->device_model->get_optional_value<bool>(ControllerComponentVariables::VerifyCsmsCommonName).value_or(true),
this->device_model->get_optional_value<bool>(ControllerComponentVariables::UseTPM).value_or(false),
this->device_model->get_optional_value<bool>(ControllerComponentVariables::VerifyCsmsAllowWildcards)
.value_or(false)};

return connection_options;
}
Expand Down Expand Up @@ -1612,9 +1612,11 @@ void ChargePoint::sign_certificate_req(const ocpp::CertificateSigningUseEnum& ce
return;
}

// TODO: use_tpm is hardcoded false here, see if it will require change
bool should_use_tpm =
this->device_model->get_optional_value<bool>(ControllerComponentVariables::UseTPM).value_or(false);

const auto csr = this->evse_security->generate_certificate_signing_request(
certificate_signing_use, country.value(), organization.value(), common.value(), false);
certificate_signing_use, country.value(), organization.value(), common.value(), should_use_tpm);
req.csr = csr;

this->awaited_certificate_signing_use_enum = certificate_signing_use;
Expand Down
21 changes: 21 additions & 0 deletions lib/ocpp/v201/ctrlr_component_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,27 @@ const ComponentVariable& UseSslDefaultVerifyPaths = {
"UseSslDefaultVerifyPaths",
}),
};
const ComponentVariable& VerifyCsmsCommonName = {
ControllerComponents::InternalCtrlr,
std::nullopt,
std::optional<Variable>({
"VerifyCsmsCommonName",
}),
};
const ComponentVariable& UseTPM = {
ControllerComponents::InternalCtrlr,
std::nullopt,
std::optional<Variable>({
"UseTPM",
}),
};
const ComponentVariable& VerifyCsmsAllowWildcards = {
ControllerComponents::InternalCtrlr,
std::nullopt,
std::optional<Variable>({
"VerifyCsmsAllowWildcards",
}),
};
const ComponentVariable& OcspRequestInterval = {
ControllerComponents::InternalCtrlr,
std::nullopt,
Expand Down

0 comments on commit e4ec1e9

Please sign in to comment.