Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pem from 0.8.3 to 1.0.0 #8318

Merged
merged 2 commits into from Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions components/core/src/error.rs
Expand Up @@ -2,6 +2,7 @@ use crate::{package::{self,
Identifiable},
tls::{ctl_gateway::Error as CtlGatewayTls,
rustls_wrapper::Error as RustlsReaderError}};
use pem;
use std::{env,
error,
ffi,
Expand Down Expand Up @@ -127,6 +128,8 @@ pub enum Error {
PackageUnpackFailed(String),
/// When an error occurs parsing an integer.
ParseIntError(num::ParseIntError),
/// When an error occurs in parsing a pem
ParsePemError(pem::PemError),
/// When parsing a string as an OS signal fails
ParseSignalError(String),
/// Occurs upon errors related to file or directory permissions.
Expand Down Expand Up @@ -331,6 +334,7 @@ impl fmt::Display for Error {
}
Error::PackageUnpackFailed(ref e) => format!("Package could not be unpacked. {}", e),
Error::ParseIntError(ref e) => format!("{}", e),
Error::ParsePemError(ref e) => format!("{}", e),
Error::ParseSignalError(ref s) => format!("Failed to parse '{}' as a signal", s),
Error::PlanMalformed => "Failed to read or parse contents of Plan file".to_string(),
Error::PermissionFailed(ref e) => e.to_string(),
Expand Down Expand Up @@ -406,6 +410,10 @@ impl From<num::ParseIntError> for Error {
fn from(err: num::ParseIntError) -> Self { Error::ParseIntError(err) }
}

impl From<pem::PemError> for Error {
fn from(err: pem::PemError) -> Self { Error::ParsePemError(err) }
}

impl From<regex::Error> for Error {
fn from(err: regex::Error) -> Self { Error::RegexParse(err) }
}
Expand Down
6 changes: 3 additions & 3 deletions components/core/src/tls/native_tls_wrapper/readers.rs
Expand Up @@ -125,9 +125,9 @@ fn certs_from_pem_file(buf: &[u8]) -> Result<Vec<Certificate>> {
// `pem::parse_many` does not return an error. It simply parses what it can and ignores the
// rest.
Certificate::from_pem(buf)?;
pem::parse_many(buf).iter()
.map(|cert| Ok(Certificate::from_der(&cert.contents)?))
.collect()
pem::parse_many(buf)?.iter()
.map(|cert| Ok(Certificate::from_der(&cert.contents)?))
.collect()
}

fn certs_from_file(file_path: &Path) -> Result<Vec<Certificate>> {
Expand Down