Skip to content

Commit 4422d39

Browse files
committed
fixup: handle more possible rsa prefixes
1 parent a3c15cd commit 4422d39

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

rust/auth-impls/src/jwt.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ fn parse_public_key_pem(pem: &str) -> Result<PKey<Public>, ()> {
5050
let body = pem
5151
.trim()
5252
.strip_prefix("-----BEGIN PUBLIC KEY-----")
53-
.ok_or(())?
54-
.strip_suffix("-----END PUBLIC KEY-----")
53+
.and_then(|pem| pem.strip_suffix("-----END PUBLIC KEY-----"))
54+
.or(pem
55+
.trim()
56+
.strip_prefix("-----BEGIN RSA PUBLIC KEY-----")
57+
.and_then(|pem| pem.strip_suffix("-----END RSA PUBLIC KEY-----")))
5558
.ok_or(())?;
5659
let body: String = body.lines().map(|line| line.trim()).collect();
5760
let body = STANDARD.decode(body).map_err(|_| ())?;

0 commit comments

Comments
 (0)