Skip to content

Commit

Permalink
Handle errors in production verify_cert fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Oct 24, 2024
1 parent 841b167 commit 03c6b37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pallets/staking/src/pck/production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ fn verify_pck_cert_chain(certificates_der: Vec<Vec<u8>>) -> Result<[u8; 65], Pck
/// Given a cerificate and a public key, verify the certificate
fn verify_cert(subject: &Certificate, issuer_pk: &VerifyingKey) -> Result<(), PckParseVerifyError> {
let verify_info = VerifyInfo::new(
subject.tbs_certificate.to_der().unwrap().into(),
Signature::new(&subject.signature_algorithm, subject.signature.as_bytes().unwrap()),
subject.tbs_certificate.to_der()?.into(),
Signature::new(
&subject.signature_algorithm,
subject.signature.as_bytes().ok_or(PckParseVerifyError::Parse)?,
),
);
Ok(issuer_pk.verify(&verify_info)?)
}
Expand Down

0 comments on commit 03c6b37

Please sign in to comment.