Skip to content

Commit 5f9c231

Browse files
authored
fix rustls CRL PEM parsing (#3013)
Closes #2990
1 parent 11d835d commit 5f9c231

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/tls.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ impl CertificateRevocationList {
453453
pub fn from_pem(pem: &[u8]) -> crate::Result<CertificateRevocationList> {
454454
Ok(CertificateRevocationList {
455455
#[cfg(feature = "__rustls")]
456-
inner: rustls_pki_types::CertificateRevocationListDer::from(pem.to_vec()),
456+
inner: rustls_pki_types::CertificateRevocationListDer::from_pem_slice(pem)
457+
.map_err(|_| crate::error::builder("invalid crl encoding"))?,
457458
})
458459
}
459460

@@ -868,6 +869,12 @@ mod tests {
868869
CertificateRevocationList::from_pem(pem).unwrap();
869870
}
870871

872+
#[cfg(feature = "__rustls")]
873+
#[test]
874+
fn invalid_crl_from_pem() {
875+
CertificateRevocationList::from_pem(b"Invalid").unwrap_err();
876+
}
877+
871878
#[cfg(feature = "__rustls")]
872879
#[test]
873880
fn crl_from_pem_bundle() {

0 commit comments

Comments
 (0)