Skip to content

Commit a37a4f3

Browse files
committed
verify_flags
1 parent cd5dc5c commit a37a4f3

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
@@ -683,6 +683,42 @@ mod _ssl {
683683
Ok(())
684684
}
685685
#[pygetset]
686+
fn verify_flags(&self) -> libc::c_ulong {
687+
unsafe {
688+
let ctx_ptr = self.ctx().as_ptr();
689+
let param = sys::SSL_CTX_get0_param(ctx_ptr);
690+
sys::X509_VERIFY_PARAM_get_flags(param)
691+
}
692+
}
693+
#[pygetset(setter)]
694+
fn set_verify_flags(&self, new_flags: libc::c_ulong, vm: &VirtualMachine) -> PyResult<()> {
695+
unsafe {
696+
let ctx_ptr = self.ctx().as_ptr();
697+
let param = sys::SSL_CTX_get0_param(ctx_ptr);
698+
let flags = sys::X509_VERIFY_PARAM_get_flags(param);
699+
let clear = flags & !new_flags;
700+
let set = !flags & new_flags;
701+
702+
if clear != 0 {
703+
if sys::X509_VERIFY_PARAM_clear_flags(param, clear) == 0 {
704+
return Err(vm.new_exception_msg(
705+
ssl_error(vm),
706+
"Failed to clear verify flags".to_owned(),
707+
));
708+
}
709+
}
710+
if set != 0 {
711+
if sys::X509_VERIFY_PARAM_set_flags(param, set) == 0 {
712+
return Err(vm.new_exception_msg(
713+
ssl_error(vm),
714+
"Failed to set verify flags".to_owned(),
715+
));
716+
}
717+
}
718+
Ok(())
719+
}
720+
}
721+
#[pygetset]
686722
fn check_hostname(&self) -> bool {
687723
self.check_hostname.load()
688724
}

0 commit comments

Comments
 (0)