Skip to content

Commit efddfce

Browse files
committed
verify_flags
1 parent 666381a commit efddfce

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

stdlib/src/ssl.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,42 @@ mod _ssl {
685685
Ok(())
686686
}
687687
#[pygetset]
688+
fn verify_flags(&self) -> libc::c_ulong {
689+
unsafe {
690+
let ctx_ptr = self.ctx().as_ptr();
691+
let param = sys::SSL_CTX_get0_param(ctx_ptr);
692+
sys::X509_VERIFY_PARAM_get_flags(param)
693+
}
694+
}
695+
#[pygetset(setter)]
696+
fn set_verify_flags(&self, new_flags: libc::c_ulong, vm: &VirtualMachine) -> PyResult<()> {
697+
unsafe {
698+
let ctx_ptr = self.ctx().as_ptr();
699+
let param = sys::SSL_CTX_get0_param(ctx_ptr);
700+
let flags = sys::X509_VERIFY_PARAM_get_flags(param);
701+
let clear = flags & !new_flags;
702+
let set = !flags & new_flags;
703+
704+
if clear != 0 {
705+
if sys::X509_VERIFY_PARAM_clear_flags(param, clear) == 0 {
706+
return Err(vm.new_exception_msg(
707+
ssl_error(vm),
708+
"Failed to clear verify flags".to_owned(),
709+
));
710+
}
711+
}
712+
if set != 0 {
713+
if sys::X509_VERIFY_PARAM_set_flags(param, set) == 0 {
714+
return Err(vm.new_exception_msg(
715+
ssl_error(vm),
716+
"Failed to set verify flags".to_owned(),
717+
));
718+
}
719+
}
720+
Ok(())
721+
}
722+
}
723+
#[pygetset]
688724
fn check_hostname(&self) -> bool {
689725
self.check_hostname.load()
690726
}

0 commit comments

Comments
 (0)