Skip to content

Commit

Permalink
chore: use rustls-pemfile 2.0.0-alpha.1
Browse files Browse the repository at this point in the history
Allows compatibility with latest rustls version, because they both use shared types from rustls-pki-types
  • Loading branch information
ravenclaw900 committed Oct 15, 2023
1 parent 25212a7 commit ab814aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude = ["examples/certs"]
[dependencies]
futures-util = { version = "0.3.28", default-features = false, features = ["std"] }
hyper = { version = "0.14.27", features = ["server", "tcp"] }
rustls-pemfile = "1.0.3"
rustls-pemfile = "2.0.0-alpha.1"
thiserror = "1.0.44"
tokio = { version = "1.29.1", features = ["net", "time"] }
tokio-rustls = "0.25.0-alpha.1"
Expand Down
11 changes: 5 additions & 6 deletions src/tlsconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ fn get_tlsacceptor_from_readers(
key_reader: &mut dyn BufRead,
protocol: HttpProtocol,
) -> Result<tokio_rustls::TlsAcceptor, TlsAcceptorError> {
let certs: Vec<_> = rustls_pemfile::certs(cert_reader)?
.into_iter()
.map(rustls::Certificate)
let certs: Vec<_> = rustls_pemfile::certs(cert_reader)
.filter_map(Result::ok)
.collect();

let key = rustls_pemfile::read_one(key_reader)?.ok_or(TlsAcceptorError::NoValidPem)?;
let key = match key {
rustls_pemfile::Item::ECKey(data)
| rustls_pemfile::Item::RSAKey(data)
| rustls_pemfile::Item::PKCS8Key(data) => rustls::PrivateKey(data),
rustls_pemfile::Item::Sec1Key(data) => data.into(),
rustls_pemfile::Item::Pkcs1Key(data) => data.into(),
rustls_pemfile::Item::Pkcs8Key(data) => data.into(),
_ => return Err(TlsAcceptorError::NoValidKey),
};

Expand Down

0 comments on commit ab814aa

Please sign in to comment.