diff --git a/src/main.rs b/src/main.rs index 781bfe8..a6ca2a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -188,9 +188,9 @@ fn auth_handler(req: Request) -> Response { Response::new(Body::from(format!("BasicAuthentication {:?}", user))) } -fn jwk_from_pem(file_path: &Path) -> Result, io::Error> { +fn jwk_from_pem(file_path: &Path) -> Result, Box> { let key_bytes = fs::read(file_path)?; - let rsa = Rsa::private_key_from_pem(key_bytes.as_slice()).unwrap(); + let rsa = Rsa::private_key_from_pem(key_bytes.as_slice())?; Ok(JWK { common: CommonParameters { algorithm: Some(Algorithm::Signature(SignatureAlgorithm::RS256)), @@ -219,7 +219,10 @@ fn get_keys(_req: Request) -> Response { None => return None, }; match ext.as_ref() { - "pem" => Some(jwk_from_pem(path.as_path()).unwrap()), + "pem" => match jwk_from_pem(path.as_path()) { + Ok(jwk) => Some(jwk), + _ => None, + }, _ => None, } })