aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgilles henaux <gill.henaux@gmail.com>2022-12-17 16:25:41 +0100
committergilles henaux <gill.henaux@gmail.com>2022-12-17 16:25:41 +0100
commit5a6c357d525360c4bf84297d745b9274e4431431 (patch)
tree647c52a83110553fccf645a5311ebde00936cc4c /src
parentdcb6395f6f75449cb34f41f0ec741af5d8d0203f (diff)
[client] Do not fail in store_known_hosts_to_file if the path has no prefix
Diffstat (limited to 'src')
-rw-r--r--src/client/certificate.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/client/certificate.rs b/src/client/certificate.rs
index c2a18f4..f0b6e6b 100644
--- a/src/client/certificate.rs
+++ b/src/client/certificate.rs
@@ -353,8 +353,9 @@ impl rustls::client::ServerCertVerifier for TofuServerVerification {
fn store_known_hosts_to_file(file: &String, store: &CertStore) -> Result<(), Box<dyn Error>> {
let path = std::path::Path::new(file);
- let prefix = path.parent().unwrap();
- std::fs::create_dir_all(prefix)?;
+ if let Some(prefix) = path.parent() {
+ std::fs::create_dir_all(prefix)?;
+ }
let mut store_file = File::create(path)?;
for entry in store {
writeln!(store_file, "{} {}", entry.0, entry.1)?;