@@ -13,6 +13,7 @@ use crate::{
1313 stream_creator:: StreamCreator ,
1414 RabbitMQStreamResult ,
1515} ;
16+
1617/// Main access point to a node
1718#[ derive( Clone ) ]
1819pub struct Environment {
@@ -108,18 +109,7 @@ impl EnvironmentBuilder {
108109 }
109110
110111 pub fn tls ( mut self , tls_configuration : TlsConfiguration ) -> EnvironmentBuilder {
111- self . 0
112- . client_options
113- . tls
114- . trust_everything ( tls_configuration. trust_everything_enabled ( ) ) ;
115- self . 0
116- . client_options
117- . tls
118- . hostname_verification_enable ( tls_configuration. hostname_verification_enabled ( ) ) ;
119- self . 0
120- . client_options
121- . tls
122- . enable ( tls_configuration. enabled ( ) ) ;
112+ self . 0 . client_options . tls = tls_configuration;
123113
124114 self
125115 }
@@ -142,28 +132,22 @@ pub struct EnvironmentOptions {
142132}
143133
144134/** Helper for tls configuration */
145- #[ derive( Clone , Copy ) ]
135+ #[ derive( Clone ) ]
146136pub struct TlsConfiguration {
147137 pub ( crate ) enabled : bool ,
148- pub ( crate ) hostname_verification : bool ,
149- pub ( crate ) trust_everything : bool ,
138+ pub ( crate ) certificate_path : String ,
150139}
151140
152141impl Default for TlsConfiguration {
153142 fn default ( ) -> TlsConfiguration {
154143 TlsConfiguration {
155144 enabled : true ,
156- trust_everything : false ,
157- hostname_verification : true ,
145+ certificate_path : String :: from ( "" ) ,
158146 }
159147 }
160148}
161149
162150impl TlsConfiguration {
163- pub fn trust_everything ( & mut self , trust_everything : bool ) {
164- self . trust_everything = trust_everything
165- }
166-
167151 pub fn enable ( & mut self , enabled : bool ) {
168152 self . enabled = enabled
169153 }
@@ -172,37 +156,25 @@ impl TlsConfiguration {
172156 self . enabled
173157 }
174158
175- pub fn hostname_verification_enable ( & mut self , hostname_verification : bool ) {
176- self . hostname_verification = hostname_verification
159+ pub fn get_root_certificates ( & self ) -> String {
160+ self . certificate_path . clone ( )
177161 }
178-
179- pub fn hostname_verification_enabled ( & self ) -> bool {
180- self . hostname_verification
181- }
182-
183- pub fn trust_everything_enabled ( & self ) -> bool {
184- self . trust_everything
162+ //
163+ pub fn add_root_certificate ( & mut self , certificate_path : String ) {
164+ self . certificate_path = certificate_path
185165 }
186166}
187167
188168pub struct TlsConfigurationBuilder ( TlsConfiguration ) ;
189169
190170impl TlsConfigurationBuilder {
191- pub fn trust_everything ( mut self , trust_everything : bool ) -> TlsConfigurationBuilder {
192- self . 0 . trust_everything = trust_everything;
193- self
194- }
195-
196171 pub fn enable ( mut self , enable : bool ) -> TlsConfigurationBuilder {
197172 self . 0 . enabled = enable;
198173 self
199174 }
200175
201- pub fn hostname_verification_enable (
202- mut self ,
203- hostname_verification : bool ,
204- ) -> TlsConfigurationBuilder {
205- self . 0 . hostname_verification = hostname_verification;
176+ pub fn add_root_certificate ( mut self , certificate_path : String ) -> TlsConfigurationBuilder {
177+ self . 0 . certificate_path = certificate_path;
206178 self
207179 }
208180
0 commit comments