1
+ use serde:: { Deserialize , Serialize } ;
2
+
3
+ #[ derive( Debug , Serialize , Deserialize ) ]
4
+ enum ClientAuth {
5
+ /**
6
+ * Client authentication is not wanted
7
+ */
8
+ NONE ,
9
+ /**
10
+ * Client authentication is wanted but not mandatory.
11
+ */
12
+ WANT ,
13
+ /**
14
+ * Client authentication is needed and mandatory.
15
+ */
16
+ NEED
17
+ }
18
+
19
+ #[ derive( Debug , Serialize , Deserialize ) ]
20
+ pub struct Ssl {
21
+
22
+ enabled : Option < bool > ,
23
+
24
+ ciphers : Vec < String > ,
25
+
26
+ client_auth : ClientAuth ,
27
+
28
+ enabled_protocols : Vec < String > ,
29
+
30
+ key_alias : Option < String > ,
31
+
32
+ key_passowrd : Option < String > ,
33
+
34
+ key_store : Option < String > ,
35
+
36
+ key_store_password : Option < String > ,
37
+
38
+ key_store_type : Option < String > ,
39
+
40
+ trust_store : Option < String > ,
41
+
42
+ trust_store_password : Option < String > ,
43
+
44
+ trust_store_type : Option < String > ,
45
+
46
+ trust_store_provider : Option < String > ,
47
+
48
+ certificate : Option < String > ,
49
+
50
+ certificate_private_key : Option < String > ,
51
+
52
+ trust_certificate : Option < String > ,
53
+
54
+ trust_certificate_private_key : Option < String > ,
55
+
56
+ protocol : Option < String > ,
57
+ }
58
+
59
+ impl Ssl {
60
+
61
+ pub ( crate ) fn new ( ssl_config : Ssl ) -> Self {
62
+ Ssl {
63
+ enabled : Some ( true ) ,
64
+ protocol : Some ( String :: from ( "TLS" ) ) ,
65
+ ciphers : ssl_config. ciphers ,
66
+ client_auth : ssl_config. client_auth ,
67
+ enabled_protocols : ssl_config. enabled_protocols ,
68
+ key_alias : ssl_config. key_alias ,
69
+ key_passowrd : ssl_config. key_passowrd ,
70
+ key_store : ssl_config. key_store ,
71
+ key_store_password : ssl_config. key_store_password ,
72
+ key_store_type : ssl_config. key_store_type ,
73
+ trust_store : ssl_config. trust_store ,
74
+ trust_store_password : ssl_config. trust_store_password ,
75
+ trust_store_type : ssl_config. trust_store_type ,
76
+ trust_store_provider : ssl_config. trust_store_provider ,
77
+ certificate : ssl_config. certificate ,
78
+ certificate_private_key : ssl_config. certificate_private_key ,
79
+ trust_certificate : ssl_config. trust_certificate ,
80
+ trust_certificate_private_key : ssl_config. trust_certificate_private_key ,
81
+ }
82
+ }
83
+ }
84
+
85
+ #[ cfg( test) ]
86
+ mod tests {
87
+ use super :: * ;
88
+
89
+ #[ test]
90
+ fn test_ssl_config ( ) {
91
+ let ssl_config = Ssl {
92
+ enabled : Some ( false ) ,
93
+ protocol : Some ( String :: from ( "TLS" ) ) ,
94
+ ciphers : Vec :: new ( ) ,
95
+ client_auth : ClientAuth :: NONE ,
96
+ enabled_protocols : Vec :: new ( ) ,
97
+ key_alias : None ,
98
+ key_passowrd : None ,
99
+ key_store : None ,
100
+ key_store_password : None ,
101
+ key_store_type : None ,
102
+ trust_store : None ,
103
+ trust_store_password : None ,
104
+ trust_store_type : None ,
105
+ trust_store_provider : None ,
106
+ certificate : None ,
107
+ certificate_private_key : None ,
108
+ trust_certificate : None ,
109
+ trust_certificate_private_key : None ,
110
+ } ;
111
+
112
+ println ! ( "ssl config : {:?}" , Ssl :: new( ssl_config) ) ;
113
+ }
114
+ }
0 commit comments