Skip to content

Commit

Permalink
Fixed a potentially bad optional access (#79)
Browse files Browse the repository at this point in the history
Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn authored Jun 5, 2024
1 parent 1ee9a96 commit aa79e39
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/evse_security/evse_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,22 @@ OCSPRequestDataList EvseSecurity::get_v2g_ocsp_request_data() {
return OCSPRequestDataList();
}

std::vector<X509Wrapper> chain = std::move(
X509CertificateBundle(secc_key_pair.info.value().certificate.value(), EncodingFormat::PEM).split());
return get_ocsp_request_data_internal(this->ca_bundle_path_map.at(CaCertificateType::V2G), chain);
std::vector<X509Wrapper> chain;

if (secc_key_pair.info.value().certificate.has_value()) {
chain = std::move(
X509CertificateBundle(secc_key_pair.info.value().certificate.value(), EncodingFormat::PEM).split());
} else if (secc_key_pair.info.value().certificate_single.has_value()) {
chain = std::move(
X509CertificateBundle(secc_key_pair.info.value().certificate_single.value(), EncodingFormat::PEM)
.split());
} else {
EVLOG_error << "Could not load v2g ocsp cache leaf chain!";
}

if (!chain.empty()) {
return get_ocsp_request_data_internal(this->ca_bundle_path_map.at(CaCertificateType::V2G), chain);
}
} catch (const CertificateLoadException& e) {
EVLOG_error << "Could not get v2g ocsp cache, certificate load failure: " << e.what();
}
Expand Down

0 comments on commit aa79e39

Please sign in to comment.