Skip to content

Commit

Permalink
Merge pull request #255 from EVerest/fix/add-password-callback-in-pro…
Browse files Browse the repository at this point in the history
…file-3

Fix: Add password callback in profile 3
  • Loading branch information
valentin-dimov authored Nov 9, 2023
2 parents 0846082 + 6a7de6e commit 9268b48
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ocpp/common/websocket/websocket_tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ tls_context WebsocketTLS::on_tls_init(std::string hostname, websocketpp::connect
if (security_profile == 3) {
const auto certificate_key_pair =
this->evse_security->get_key_pair(CertificateSigningUseEnum::ChargingStationCertificate);

if (certificate_key_pair.has_value() && certificate_key_pair.value().password.has_value()) {
std::string passwd = certificate_key_pair.value().password.value();
context->set_password_callback(
[passwd](auto max_len, auto purpose) { return passwd.substr(0, max_len); });
}

if (!certificate_key_pair.has_value()) {
EVLOG_AND_THROW(std::runtime_error(
"Connecting with security profile 3 but no client side certificate is present or valid"));
Expand Down

0 comments on commit 9268b48

Please sign in to comment.