Skip to content

Commit

Permalink
Merge pull request #994 from sozu-proxy/devel/fdubois/fix/pki-helper
Browse files Browse the repository at this point in the history
fix(command): retrieve name and san from slice
  • Loading branch information
FlorentinDUBOIS authored Sep 21, 2023
2 parents 24c4407 + a5412b9 commit 674a6e1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions command/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ use crate::proto::command::TlsVersion;
pub enum CertificateError {
#[error("Could not parse PEM certificate from bytes: {0}")]
InvalidCertificate(String),
#[error("failed to parse certificate common name attribute, {0}")]
InvalidCommonName(String),
#[error("failed to parse certificate subject alternate names attribute, {0}")]
InvalidSubjectAlternateNames(String),
#[error("failed to parse tls version '{0}'")]
InvalidTlsVersion(String),
}
Expand Down Expand Up @@ -52,15 +48,15 @@ pub fn get_cn_and_san_attributes(pem: &Pem) -> Result<HashSet<String>, Certifica
names.insert(
name.as_str()
.map(String::from)
.map_err(|err| CertificateError::InvalidCommonName(err.to_string()))?,
.unwrap_or_else(|_| String::from_utf8_lossy(name.as_slice()).to_string()),
);
}

for name in x509.subject().iter_by_oid(&OID_X509_EXT_SUBJECT_ALT_NAME) {
names.insert(
name.as_str()
.map(String::from)
.map_err(|err| CertificateError::InvalidSubjectAlternateNames(err.to_string()))?,
.unwrap_or_else(|_| String::from_utf8_lossy(name.as_slice()).to_string()),
);
}

Expand Down

0 comments on commit 674a6e1

Please sign in to comment.