Skip to content

Commit

Permalink
fix sslkeylog canonicalize: seems to require the path to exist...
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDC committed Nov 14, 2024
1 parent 863581e commit b965247
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rama-tls/src/keylog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ use std::{
/// Paths are case-sensitive by default for rama, as utf-8 compatible.
/// Normalize yourself prior to passing a path to this function if you're concerned.
pub fn new_key_log_file_handle(path: String) -> Result<KeyLogFileHandle, OpaqueError> {
let path = std::fs::canonicalize(path).context("canonicalize keylog path")?;
let path: PathBuf = path
.parse()
.with_context(|| format!("parse path str as Path: {path}"))?;

if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)
.with_context(|| format!("create parent dir(s) at {parent:?} for key log file"))?;
}

let path = std::fs::canonicalize(&path)
.with_context(|| format!("canonicalize keylog path: {path:?}"))?;

let mapping = GLOBAL_KEY_LOG_FILE_MAPPING.get_or_init(Default::default);
if let Some(handle) = mapping.read().get(&path).cloned() {
Expand Down

0 comments on commit b965247

Please sign in to comment.