1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::time::Duration;

/// Certificate details in various supported formats for use with TLS client authentication.
#[derive(Clone, Debug)]
pub enum ClientCertificate {
    SeparatePem {
        cert_bytes: Vec<u8>,
        key_bytes: Option<Vec<u8>>,
    },
    CombinedPkcs12 {
        cert_bytes: Vec<u8>,
    },
}

/// TCP and TLS settings for connecting to a KMIP server.
#[derive(Clone, Default, Debug)]
pub struct ConnectionSettings {
    /// HSM host/domain name
    pub host: String,

    /// HSM port number
    pub port: u16,

    /// HSM username
    pub username: Option<String>,

    /// HSM password
    pub password: Option<String>,

    /// Disable security features such as server certificate verification
    pub insecure: bool,

    /// Client certificate authentication
    pub client_cert: Option<ClientCertificate>,

    /// Server certificate bytes in PEM format
    pub server_cert: Option<Vec<u8>>,

    /// Server CA certificate bytes in PEM format
    pub ca_cert: Option<Vec<u8>>,

    /// TCP connect timeout
    pub connect_timeout: Option<Duration>,

    /// TCP read timeout
    pub read_timeout: Option<Duration>,

    /// TCP write timeout
    pub write_timeout: Option<Duration>,

    /// Maximum number of HSM response bytes to accept
    pub max_response_bytes: Option<u32>,
}