Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,14 @@ pub fn write_cert(
let cert_path: PathBuf = path.join(format!("{cert_str}.{encoding}"));

// Write cert into directory
let mut file = if cert_path.exists() {
std::fs::OpenOptions::new()
.write(true)
.truncate(true)
.open(cert_path)
.context(format!("Unable to overwrite {cert_str} cert contents"))?
} else {
fs::File::create(cert_path).context(format!("Unable to create {cert_str} certificate"))?
};
let mut file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&cert_path)
.context(format!(
"unable to create or overwrite {cert_str} certificate"
))?;

file.write(&bytes)
.context(format!("unable to write data to file {:?}", file))?;
Expand Down