Merge branch 'master' of git.shimun.net:shimun/ssh-cert-dist
This commit is contained in:
@@ -12,14 +12,18 @@ pub async fn read_certs(
|
||||
ca: &PublicKey,
|
||||
path: impl AsRef<Path>,
|
||||
) -> anyhow::Result<Vec<Certificate>> {
|
||||
read_dir(path.as_ref().join(ca_dir(ca))).await
|
||||
let ca_dir = path.as_ref().join(ca_dir(ca));
|
||||
if !ca_dir.exists() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
read_dir(&ca_dir).await
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
pub async fn read_dir(path: impl AsRef<Path> + Debug) -> anyhow::Result<Vec<Certificate>> {
|
||||
let mut dir = fs::read_dir(path.as_ref())
|
||||
.await
|
||||
.context("read certs dir")?;
|
||||
.with_context(|| format!("read certs dir '{:?}'", path.as_ref()))?;
|
||||
let mut certs = Vec::new();
|
||||
while let Some(entry) = dir.next_entry().await? {
|
||||
//TODO: investigate why path().ends_with doesn't work
|
||||
|
Reference in New Issue
Block a user