Skip to main content

kmip_protocol/net/
config.rs

1use std::time::Duration;
2
3#[derive(Clone, Default, Debug, PartialEq, Eq)]
4pub struct TlsClientAuth {
5    /// Client certificate bytes in PEM format.
6    pub cert_bytes: Vec<u8>,
7
8    /// Client private key bytes in PEM format.
9    pub private_key_bytes: Vec<u8>,
10}
11
12#[derive(Clone, Default, Debug, PartialEq, Eq)]
13pub enum TlsServerAuth {
14    /// Do not verify the identify of the server.
15    None,
16
17    /// Use only certificates provided in the default trust store.
18    #[default]
19    Default,
20
21    /// The PEM encoded bytes of a certificate to trurst directly, e.g. a
22    /// self-signed certificate.
23    ///
24    /// TODO: Add support for verifying certificates by their fingerprint.
25    TrustCertificate(Vec<u8>),
26
27    /// The PEM encoded bytes of the certificate of a Certificate Authority
28    /// to add to the certificate trust store in order to be able to verify
29    /// certificates issued by this authority, e.g. an in-house custom CA
30    /// not present in the default trust store.
31    TrustCertificateAuthority(Vec<u8>),
32}
33
34/// TCP and TLS settings for connecting to a KMIP server.
35#[derive(Clone, Default, Debug, PartialEq, Eq)]
36pub struct ConnectionSettings {
37    /// HSM host/domain name/IP address.
38    pub host: String,
39
40    /// HSM port number.
41    pub port: u16,
42
43    /// HSM username
44    pub username: Option<String>,
45
46    /// HSM password
47    pub password: Option<String>,
48
49    /// Details needed to enable the TLS client to respond to a challenge from
50    /// the server for the client to prove its identity.
51    pub tls_client_auth: Option<TlsClientAuth>,
52
53    /// Details used to verify the identify of the TLS server.
54    pub tls_server_auth: TlsServerAuth,
55
56    /// Server name for use with TLS SNI to direct the server to identify
57    /// itself using a particular certificate, for servers that have more
58    /// than one.
59    pub tls_server_name: Option<String>,
60
61    /// TCP connect timeout
62    pub connect_timeout: Option<Duration>,
63
64    /// TCP read timeout
65    pub read_timeout: Option<Duration>,
66
67    /// TCP write timeout
68    pub write_timeout: Option<Duration>,
69
70    /// Maximum number of HSM response bytes to accept
71    pub max_response_bytes: Option<u32>,
72}