Skip to content

Commit

Permalink
Remove unneeded checks for private key
Browse files Browse the repository at this point in the history
  • Loading branch information
Arend Lapere committed Apr 20, 2023
1 parent 8fa929d commit f491bcf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [v0.2.12]

### Fixed

* Remove unneeded private key check for PKCS#8

## [v0.2.11]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "native-tls"
version = "0.2.11"
version = "0.2.12"
authors = ["Steven Fackler <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "A wrapper over a platform's native TLS implementation"
Expand Down
4 changes: 0 additions & 4 deletions src/imp/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ impl Identity {
}

pub fn from_pkcs8(buf: &[u8], key: &[u8]) -> Result<Identity, Error> {
if !key.starts_with(b"-----BEGIN PRIVATE KEY-----") {
return Err(Error::NotPkcs8);
}

let pkey = PKey::private_key_from_pem(key)?;
let mut cert_chain = X509::stack_from_pem(buf)?.into_iter();
let cert = cert_chain.next().ok_or(Error::EmptyChain)?;
Expand Down
4 changes: 0 additions & 4 deletions src/imp/schannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ impl Identity {
}

pub fn from_pkcs8(pem: &[u8], key: &[u8]) -> Result<Identity, Error> {
if !key.starts_with(b"-----BEGIN PRIVATE KEY-----") {
return Err(io::Error::new(io::ErrorKind::InvalidInput, "not a PKCS#8 key").into());
}

let mut store = Memory::new()?.into_store();
let mut cert_iter = pem::PemBlock::new(pem).into_iter();
let leaf = cert_iter.next().ok_or_else(|| {
Expand Down

0 comments on commit f491bcf

Please sign in to comment.