Skip to content

Commit

Permalink
Support reading PKCS#1 and SEC1 private keys with Rustls (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear authored Aug 21, 2024
1 parent f657a97 commit d34c43a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog], and this project adheres to
# Unreleased

- **changed**: Updated `tower` from `0.4` to `0.5`.
- **added**: Support reading PKCS\#1 and SEC1 private keys with Rustls.

# 0.7.1 (31. July 2024)

Expand Down
6 changes: 3 additions & 3 deletions src/tls_rustls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ async fn config_from_pem_chain_file(
let key_cert: PrivateKeyDer = match rustls_pemfile::read_one(&mut key.as_ref())?
.ok_or_else(|| io_other("could not parse pem file"))?
{
Item::Pkcs8Key(key) => {
Ok(PrivateKeyDer::try_from(key.secret_pkcs8_der().to_vec()).map_err(io_other)?)
}
Item::Pkcs8Key(key) => Ok(key.into()),
Item::Sec1Key(key) => Ok(key.into()),
Item::Pkcs1Key(key) => Ok(key.into()),
x => Err(io_other(format!(
"invalid certificate format, received: {x:?}"
))),
Expand Down

0 comments on commit d34c43a

Please sign in to comment.