1use kinetic_doc_derive::FieldDoc;
4use serde::{Deserialize, Serialize};
5use snafu::Snafu;
6use std::path::PathBuf;
7
8#[derive(Debug, Snafu)]
9pub enum Error {
10 #[snafu(display("Failed to read TLS certificate file: {}", path.display()))]
11 ReadCert {
12 path: PathBuf,
13 source: std::io::Error,
14 },
15 #[snafu(display("TLS configuration is not yet fully implemented, but was enabled."))]
16 Unimplemented,
17}
18
19type Result<T, E = Error> = std::result::Result<T, E>;
20
21#[derive(Clone, Debug, Deserialize, Serialize, Default, FieldDoc)]
24pub struct TlsConfig {
25 #[serde(default)]
27 #[doc_field(default = "false")]
28 pub enabled: bool,
29
30 #[doc_field(example = "/etc/ssl/certs/ca-bundle.crt")]
32 pub ca_file: Option<PathBuf>,
33
34 #[doc_field(example = "/etc/kinetic/tls/client.crt")]
36 pub crt_file: Option<PathBuf>,
37
38 #[doc_field(secret, example = "/etc/kinetic/tls/client.key")]
40 pub key_file: Option<PathBuf>,
41
42 #[serde(default)]
44 #[doc_field(default = "false")]
45 pub insecure_skip_verify: bool,
46}
47
48impl TlsConfig {
49 pub fn build(&self) -> Result<()> {
55 if self.insecure_skip_verify || self.enabled {
56 return Err(Error::Unimplemented);
57 }
58
59 Ok(())
60 }
61}