drogue_bazaar/core/tls/
auth.rs1#[derive(Clone, Copy)]
3pub enum TlsMode {
4 NoClient,
6 Client,
8}
9
10pub struct TlsAuthConfig {
12 pub mode: TlsMode,
13 #[cfg(feature = "openssl")]
14 pub psk: Option<
15 Box<
16 dyn Fn(
17 &mut openssl::ssl::SslRef,
18 Option<&[u8]>,
19 &mut [u8],
20 ) -> Result<usize, std::io::Error>
21 + Sync
22 + Send,
23 >,
24 >,
25}
26
27impl Default for TlsAuthConfig {
28 fn default() -> Self {
29 Self {
30 mode: TlsMode::NoClient,
31 #[cfg(feature = "openssl")]
32 psk: None,
33 }
34 }
35}
36
37pub trait WithTlsAuthConfig {
39 fn with_tls_auth_config(&self, tls_config: TlsAuthConfig) -> Option<TlsAuthConfig>;
40}
41
42impl WithTlsAuthConfig for bool {
44 fn with_tls_auth_config(&self, tls_config: TlsAuthConfig) -> Option<TlsAuthConfig> {
45 if *self {
46 None
47 } else {
48 Some(tls_config)
49 }
50 }
51}