mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-12-29 22:00:31 +00:00
Improve error in signature verification
This commit is contained in:
parent
b53ec4d980
commit
5cd0b21ae3
2 changed files with 12 additions and 6 deletions
|
@ -100,6 +100,9 @@ pub(crate) enum ErrorKind {
|
|||
#[error("Couldn't sign digest")]
|
||||
Signature(#[from] signature::Error),
|
||||
|
||||
#[error("Couldn't read signature")]
|
||||
ReadSignature(signature::Error),
|
||||
|
||||
#[error("Couldn't parse the signature header")]
|
||||
HeaderValidation(#[from] actix_web::http::header::InvalidHeaderValue),
|
||||
|
||||
|
|
|
@ -113,9 +113,11 @@ async fn do_verify(
|
|||
) -> Result<(), Error> {
|
||||
let public_key = RsaPublicKey::from_public_key_pem(public_key.trim())?;
|
||||
|
||||
let span = tracing::Span::current();
|
||||
web::block(move || {
|
||||
span.in_scope(|| {
|
||||
let decoded = base64::decode(signature)?;
|
||||
let signature = Signature::from_bytes(&decoded)?;
|
||||
let signature = Signature::from_bytes(&decoded).map_err(ErrorKind::ReadSignature)?;
|
||||
let hashed = Sha256::new_with_prefix(signing_string.as_bytes());
|
||||
|
||||
let verifying_key = VerifyingKey::new_with_prefix(public_key);
|
||||
|
@ -123,6 +125,7 @@ async fn do_verify(
|
|||
|
||||
Ok(()) as Result<(), Error>
|
||||
})
|
||||
})
|
||||
.await??;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue