Skip to content

Commit 1bdfb91

Browse files
authored
Update pem dependency to 2.x (#303)
- updating this removes the duplicate base64 dependency as pem 1.x used base64 0.13 still
1 parent a470ed0 commit 1bdfb91

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ serde = {version = "1.0", features = ["derive"] }
1818
ring = { version = "0.16.5", features = ["std"] }
1919
base64 = "0.21.0"
2020
# For PEM decoding
21-
pem = {version = "1", optional = true}
21+
pem = {version = "2", optional = true}
2222
simple_asn1 = {version = "0.6", optional = true}
2323

2424
[dev-dependencies]

src/pem/decoder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,21 @@ impl PemEncodedKey {
5353
pub fn new(input: &[u8]) -> Result<PemEncodedKey> {
5454
match pem::parse(input) {
5555
Ok(content) => {
56-
let pem_contents = content.contents;
57-
let asn1_content = match simple_asn1::from_der(pem_contents.as_slice()) {
56+
let asn1_content = match simple_asn1::from_der(content.contents()) {
5857
Ok(asn1) => asn1,
5958
Err(_) => return Err(ErrorKind::InvalidKeyFormat.into()),
6059
};
6160

62-
match content.tag.as_ref() {
61+
match content.tag().as_ref() {
6362
// This handles a PKCS#1 RSA Private key
6463
"RSA PRIVATE KEY" => Ok(PemEncodedKey {
65-
content: pem_contents,
64+
content: content.into_contents(),
6665
asn1: asn1_content,
6766
pem_type: PemType::RsaPrivate,
6867
standard: Standard::Pkcs1,
6968
}),
7069
"RSA PUBLIC KEY" => Ok(PemEncodedKey {
71-
content: pem_contents,
70+
content: content.into_contents(),
7271
asn1: asn1_content,
7372
pem_type: PemType::RsaPublic,
7473
standard: Standard::Pkcs1,
@@ -107,7 +106,7 @@ impl PemEncodedKey {
107106
}
108107
};
109108
Ok(PemEncodedKey {
110-
content: pem_contents,
109+
content: content.into_contents(),
111110
asn1: asn1_content,
112111
pem_type,
113112
standard: Standard::Pkcs8,

0 commit comments

Comments
 (0)