fix constant panics when keystore is weird
This commit is contained in:
parent
750aabc83c
commit
afbd1d2ba0
|
@ -70,13 +70,11 @@ pub async fn dnclient(
|
||||||
let client_keys = host_in_ks
|
let client_keys = host_in_ks
|
||||||
.client_keys
|
.client_keys
|
||||||
.iter()
|
.iter()
|
||||||
.find(|u| u.id == req.counter as u64)
|
.find(|u| u.id == req.counter as u64);
|
||||||
.unwrap();
|
|
||||||
let client_keys_2 = host_in_ks
|
let client_keys_2 = host_in_ks
|
||||||
.client_keys
|
.client_keys
|
||||||
.iter()
|
.iter()
|
||||||
.find(|u| u.id == host_in_ks.current_client_key)
|
.find(|u| u.id == host_in_ks.current_client_key);;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let signature = match Signature::from_slice(&req.signature) {
|
let signature = match Signature::from_slice(&req.signature) {
|
||||||
Ok(sig) => sig,
|
Ok(sig) => sig,
|
||||||
|
@ -92,15 +90,20 @@ pub async fn dnclient(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if client_keys
|
let mut valid = false;
|
||||||
.ed_pub
|
|
||||||
.verify(req.message.as_bytes(), &signature)
|
if let Some(client_keys) = client_keys {
|
||||||
.is_err()
|
if client_keys.ed_pub.verify(req.message.as_bytes(), &signature).is_ok() {
|
||||||
&& client_keys_2
|
valid = true;
|
||||||
.ed_pub
|
}
|
||||||
.verify(req.message.as_bytes(), &signature)
|
}
|
||||||
.is_err()
|
if let Some(client_keys_2) = client_keys_2 {
|
||||||
{
|
if client_keys_2.ed_pub.verify(req.message.as_bytes(), &signature).is_ok() {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !valid {
|
||||||
// Be intentionally vague as the message is invalid.
|
// Be intentionally vague as the message is invalid.
|
||||||
warn!("! invalid signature from {}", host);
|
warn!("! invalid signature from {}", host);
|
||||||
return HttpResponse::Unauthorized().json(vec![APIError {
|
return HttpResponse::Unauthorized().json(vec![APIError {
|
||||||
|
|
Loading…
Reference in New Issue