Skip to content

Commit

Permalink
Fix #56
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed May 6, 2024
1 parent dfae4c0 commit e0e16fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pub(crate) fn server_load_certs(path: &Path) -> Result<Vec<CertificateDer<'stati
for cert in rustls_pemfile::certs(&mut BufReader::new(File::open(path)?)) {
res.push(cert?);
}
if res.is_empty() {
return Err("No certificates found".into());
}
Ok(res)
}

Expand All @@ -59,5 +62,14 @@ pub(crate) fn server_load_keys(path: &Path) -> Result<Vec<PrivateKeyDer<'static>
for key in rustls_pemfile::rsa_private_keys(&mut BufReader::new(File::open(path)?)) {
res.push(PrivateKeyDer::from(key?));
}
for key in rustls_pemfile::pkcs8_private_keys(&mut BufReader::new(File::open(path)?)) {
res.push(PrivateKeyDer::from(key?));
}
for key in rustls_pemfile::ec_private_keys(&mut BufReader::new(File::open(path)?)) {
res.push(PrivateKeyDer::from(key?));
}
if res.is_empty() {
return Err("No keys found".into());
}
Ok(res)
}

0 comments on commit e0e16fc

Please sign in to comment.