Skip to content

Commit 69cedf6

Browse files
committed
fspath
1 parent d30e055 commit 69cedf6

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

stdlib/src/ssl.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,6 @@ mod _ssl {
854854
if let (None, None, None) = (&args.cafile, &args.capath, &args.cadata) {
855855
return Err(vm.new_type_error("cafile, capath and cadata cannot be all omitted"));
856856
}
857-
if let Some(cafile) = &args.cafile {
858-
cafile.ensure_no_nul(vm)?
859-
}
860-
if let Some(capath) = &args.capath {
861-
capath.ensure_no_nul(vm)?
862-
}
863857

864858
#[cold]
865859
fn invalid_cadata(vm: &VirtualMachine) -> PyBaseExceptionRef {
@@ -889,11 +883,10 @@ mod _ssl {
889883
}
890884

891885
if args.cafile.is_some() || args.capath.is_some() {
892-
ctx.load_verify_locations(
893-
args.cafile.as_ref().map(|s| s.as_str().as_ref()),
894-
args.capath.as_ref().map(|s| s.as_str().as_ref()),
895-
)
896-
.map_err(|e| convert_openssl_error(vm, e))?;
886+
let cafile_path = args.cafile.map(|p| p.to_path_buf(vm)).transpose()?;
887+
let capath_path = args.capath.map(|p| p.to_path_buf(vm)).transpose()?;
888+
ctx.load_verify_locations(cafile_path.as_deref(), capath_path.as_deref())
889+
.map_err(|e| convert_openssl_error(vm, e))?;
897890
}
898891

899892
Ok(())
@@ -1066,9 +1059,9 @@ mod _ssl {
10661059
#[derive(FromArgs)]
10671060
struct LoadVerifyLocationsArgs {
10681061
#[pyarg(any, default)]
1069-
cafile: Option<PyStrRef>,
1062+
cafile: Option<FsPath>,
10701063
#[pyarg(any, default)]
1071-
capath: Option<PyStrRef>,
1064+
capath: Option<FsPath>,
10721065
#[pyarg(any, default)]
10731066
cadata: Option<Either<PyStrRef, ArgBytesLike>>,
10741067
}

0 commit comments

Comments
 (0)