wallet_rpc_server: fix ssl_allowed_fingerprints hex parsing

This commit is contained in:
selsta
2026-04-21 13:33:42 +02:00
parent 94c2ed34c2
commit 3d2eb0ea8a

View File

@@ -4770,10 +4770,25 @@ namespace tools
ssl_allowed_fingerprints.reserve(req.ssl_allowed_fingerprints.size());
for (const std::string &fp: req.ssl_allowed_fingerprints)
{
ssl_allowed_fingerprints.push_back({});
std::vector<uint8_t> &v = ssl_allowed_fingerprints.back();
for (auto c: fp)
v.push_back(c);
std::vector<uint8_t> decoded;
try
{
decoded = epee::from_hex_locale::to_vector(fp);
}
catch (const std::exception &)
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = "ssl_allowed_fingerprints[] entries must be hex-encoded SHA-256 values";
return false;
}
if (decoded.size() != SSL_FINGERPRINT_SIZE)
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = "Each ssl_allowed_fingerprints[] entry must decode to exactly " BOOST_PP_STRINGIZE(SSL_FINGERPRINT_SIZE) " bytes";
return false;
}
ssl_allowed_fingerprints.emplace_back(std::move(decoded));
}
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_enabled;