From e2df099992f19968f90ebd18bacf2b8ca8daa1f2 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Tue, 25 Jun 2024 15:03:26 -0400 Subject: [PATCH] implement SSL_get_verify_mode We already implemented `SSL_CTX_get_verify_mode` and had all the pieces laying around for the `SSL` equiv. Implementing this for `SSL` objects will make writing a unit test for a piece of the `SSL_CONF_` API easier. --- rustls-libssl/MATRIX.md | 2 +- rustls-libssl/build.rs | 1 + rustls-libssl/src/entry.rs | 6 ++++++ rustls-libssl/src/lib.rs | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rustls-libssl/MATRIX.md b/rustls-libssl/MATRIX.md index 8a0ad77..950adf5 100644 --- a/rustls-libssl/MATRIX.md +++ b/rustls-libssl/MATRIX.md @@ -379,7 +379,7 @@ | `SSL_get_state` | | | :white_check_mark: | | `SSL_get_verify_callback` | | | | | `SSL_get_verify_depth` | | | :white_check_mark: | -| `SSL_get_verify_mode` | | | | +| `SSL_get_verify_mode` | | | :white_check_mark: | | `SSL_get_verify_result` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `SSL_get_version` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `SSL_get_wbio` | | :white_check_mark: | :white_check_mark: | diff --git a/rustls-libssl/build.rs b/rustls-libssl/build.rs index 20670c0..3f44ac0 100644 --- a/rustls-libssl/build.rs +++ b/rustls-libssl/build.rs @@ -156,6 +156,7 @@ const ENTRYPOINTS: &[&str] = &[ "SSL_get_SSL_CTX", "SSL_get_state", "SSL_get_verify_depth", + "SSL_get_verify_mode", "SSL_get_verify_result", "SSL_get_version", "SSL_get_wbio", diff --git a/rustls-libssl/src/entry.rs b/rustls-libssl/src/entry.rs index 4a372e6..fe67600 100644 --- a/rustls-libssl/src/entry.rs +++ b/rustls-libssl/src/entry.rs @@ -1362,6 +1362,12 @@ entry! { } } +entry! { + pub fn _SSL_get_verify_mode(ssl: *const SSL) -> c_int { + try_clone_arc!(ssl).get().get_verify_mode().into() + } +} + entry! { pub fn _SSL_set_verify_depth(ssl: *mut SSL, depth: c_int) { try_clone_arc!(ssl).get_mut().set_verify_depth(depth) diff --git a/rustls-libssl/src/lib.rs b/rustls-libssl/src/lib.rs index ccc4046..3a8ede3 100644 --- a/rustls-libssl/src/lib.rs +++ b/rustls-libssl/src/lib.rs @@ -890,6 +890,10 @@ impl Ssl { self.verify_mode = mode; } + fn get_verify_mode(&self) -> VerifyMode { + self.verify_mode + } + fn set_verify_depth(&mut self, depth: c_int) { self.verify_depth = depth; }