Skip to content

Commit

Permalink
Config value when testing csms name wildcards
Browse files Browse the repository at this point in the history
resolves #494

Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn committed Mar 6, 2024
1 parent bda022e commit cddd1a3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions config/v16/profile_schemas/Internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@
"readOnly": true,
"default": true
},
"VerifyCsmsAllowWildcards": {
"$comment": "Allow wildcards when verifying the CSMS commonName",
"type": "boolean",
"readOnly": true,
"default": false
},
"OcspRequestInterval": {
"$comment": "Interval in seconds used to request OCSP revocation status information on the CSO Sub-CA certificates",
"type": "integer",
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/common/websocket/websocket_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct WebsocketConnectionOptions {
std::optional<std::string> hostName;
bool verify_csms_common_name;
bool use_tpm_tls;
bool verify_csms_allow_wildcards;
};

enum class ConnectionFailedReason {
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 @@ -84,6 +84,7 @@ class ChargePointConfiguration {
KeyValue getUseSslDefaultVerifyPathsKeyValue();
bool getVerifyCsmsCommonName();
KeyValue getVerifyCsmsCommonNameKeyValue();
bool getVerifyCsmsAllowWildcards();
bool getUseTPM();
std::string getSupportedMeasurands();
KeyValue getSupportedMeasurandsKeyValue();
Expand Down
6 changes: 5 additions & 1 deletion lib/ocpp/common/websocket/websocket_tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ tls_context WebsocketTLS::on_tls_init(std::string hostname, websocketpp::connect
// Verify hostname
X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();

X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_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);
}

// Set the host and parameter check
X509_VERIFY_PARAM_set1_host(param, hostname.c_str(), hostname.length());
Expand Down
5 changes: 5 additions & 0 deletions lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ bool ChargePointConfiguration::getUseTPM() {
return this->config["Internal"]["UseTPM"];
}

bool ChargePointConfiguration::getVerifyCsmsAllowWildcards() {
return this->config["Internal"]["VerifyCsmsAllowWildcards"];
}


std::string ChargePointConfiguration::getSupportedMeasurands() {
return this->config["Internal"]["SupportedMeasurands"];
}
Expand Down
4 changes: 3 additions & 1 deletion lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ WebsocketConnectionOptions ChargePointImpl::get_ws_connection_options() {
this->configuration->getAdditionalRootCertificateCheck(),
this->configuration->getHostName(),
this->configuration->getVerifyCsmsCommonName(),
this->configuration->getUseTPM()};
this->configuration->getUseTPM(),
this->configuration->getVerifyCsmsAllowWildcards()
};
return connection_options;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,9 @@ 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
true, // verify_csms_common_name
false, // use tpm
false // verify_csms_allow_wildcards
};

return connection_options;
Expand Down

0 comments on commit cddd1a3

Please sign in to comment.