Skip to content

Commit

Permalink
Add option to allow security level 0 connection in OCPP 2.0.1
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Emmers <[email protected]>
  • Loading branch information
marcemmers committed Nov 1, 2024
1 parent abdf54c commit 60980b5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
16 changes: 16 additions & 0 deletions config/v201/component_config/standardized/InternalCtrlr.json
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,22 @@
"minimum": 1,
"default": "60",
"type": "integer"
},
"AllowSecurityLevelZeroConnections": {
"variable_name": "AllowSecurityLevelZeroConnections",
"characteristics": {
"supportsMonitoring": false,
"dataType": "boolean"
},
"attributes": [
{
"type": "Actual",
"mutability": "ReadOnly"
}
],
"description": "If enabled the transactions that were active before shutdown will be resumed, if possible",
"default": false,
"type": "boolean"
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v201/ctrlr_component_variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extern const ComponentVariable& ClientCertificateExpireCheckIntervalSeconds;
extern const ComponentVariable& MessageQueueSizeThreshold;
extern const ComponentVariable& MaxMessageSize;
extern const ComponentVariable& ResumeTransactionsOnBoot;
extern const ComponentVariable& AllowSecurityLevelZeroConnections;
extern const ComponentVariable& AlignedDataCtrlrEnabled;
extern const ComponentVariable& AlignedDataCtrlrAvailable;
extern const RequiredComponentVariable& AlignedDataInterval;
Expand Down
14 changes: 8 additions & 6 deletions lib/ocpp/v201/connectivity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ ConnectivityManager::get_network_connection_profile(const int32_t configuration_

for (const auto& network_profile : this->network_connection_profiles) {
if (network_profile.configurationSlot == configuration_slot) {
switch (auto security_profile = network_profile.connectionData.securityProfile) {
case security::OCPP_1_6_ONLY_UNSECURED_TRANSPORT_WITHOUT_BASIC_AUTHENTICATION:
throw std::invalid_argument("security_profile = " + std::to_string(security_profile) +
" not officially allowed in OCPP 2.0.1");
default:
break;
if (!this->device_model
.get_optional_value<bool>(ControllerComponentVariables::AllowSecurityLevelZeroConnections)
.value_or(false) &&
network_profile.connectionData.securityProfile ==
security::OCPP_1_6_ONLY_UNSECURED_TRANSPORT_WITHOUT_BASIC_AUTHENTICATION) {
throw std::invalid_argument(
"security_profile = " + std::to_string(network_profile.connectionData.securityProfile) +
" not officially allowed in OCPP 2.0.1");
}

return network_profile.connectionData;
Expand Down
7 changes: 7 additions & 0 deletions lib/ocpp/v201/ctrlr_component_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ const ComponentVariable& ResumeTransactionsOnBoot = {
"ResumeTransactionsOnBoot",
}),
};
const ComponentVariable& AllowSecurityLevelZeroConnections = {
ControllerComponents::InternalCtrlr,
std::nullopt,
std::optional<Variable>({
"AllowSecurityLevelZeroConnections",
}),
};
const ComponentVariable& AlignedDataCtrlrEnabled = {
ControllerComponents::AlignedDataCtrlr,
std::nullopt,
Expand Down

0 comments on commit 60980b5

Please sign in to comment.