diff --git a/Cargo.toml b/Cargo.toml index 502fcc8de..b813ea2d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ itertools = "0.12" log = "0.4" percent-encoding = "2" rustls = { version = "^0.22.1", optional = true } -rustls-pemfile = { version = "1.0.1", optional = true } +rustls-pemfile = { version = "2.0.0", optional = true } seahash = "4" serde = {version = "1.0", features = ["derive"]} serde_json = "1.0" diff --git a/src/service_account.rs b/src/service_account.rs index 8bd72ae4d..d3ce9ba10 100644 --- a/src/service_account.rs +++ b/src/service_account.rs @@ -39,18 +39,17 @@ fn append_base64 + ?Sized>(s: &T, out: &mut String) { /// Decode a PKCS8 formatted RSA key. fn decode_rsa_key(pem_pkcs8: &str) -> Result { - let private_keys = rustls_pemfile::pkcs8_private_keys(&mut pem_pkcs8.as_bytes()); + let private_key = rustls_pemfile::pkcs8_private_keys(&mut pem_pkcs8.as_bytes()).next(); - match private_keys { - Ok(mut keys) if !keys.is_empty() => { - keys.truncate(1); - Ok(PrivateKeyDer::Pkcs8(keys.remove(0).into())) + match private_key { + Some(Ok(key)) => { + Ok(PrivateKeyDer::Pkcs8(key.into())) } - Ok(_) => Err(io::Error::new( + None => Err(io::Error::new( io::ErrorKind::InvalidInput, "Not enough private keys in PEM", )), - Err(_) => Err(io::Error::new( + Some(Err(_)) => Err(io::Error::new( io::ErrorKind::InvalidInput, "Error reading key from PEM", )),