@@ -171,10 +171,10 @@ pub struct Config {
171171 pub ( crate ) dbname : Option < String > ,
172172 pub ( crate ) options : Option < String > ,
173173 pub ( crate ) application_name : Option < String > ,
174- pub ( crate ) ssl_cert : Option < PathBuf > ,
175- pub ( crate ) ssl_key : Option < PathBuf > ,
174+ pub ( crate ) ssl_cert : Option < Vec < u8 > > ,
175+ pub ( crate ) ssl_key : Option < Vec < u8 > > ,
176176 pub ( crate ) ssl_mode : SslMode ,
177- pub ( crate ) ssl_root_cert : Option < PathBuf > ,
177+ pub ( crate ) ssl_root_cert : Option < Vec < u8 > > ,
178178 pub ( crate ) host : Vec < Host > ,
179179 pub ( crate ) port : Vec < u16 > ,
180180 pub ( crate ) connect_timeout : Option < Duration > ,
@@ -282,30 +282,30 @@ impl Config {
282282 self . application_name . as_deref ( )
283283 }
284284
285- /// Sets the location of the client SSL certificate file .
285+ /// Sets the client SSL certificate in PEM format .
286286 ///
287287 /// Defaults to `None`.
288- pub fn ssl_cert ( & mut self , ssl_cert : & str ) -> & mut Config {
289- self . ssl_cert = Some ( PathBuf :: from ( ssl_cert) ) ;
288+ pub fn ssl_cert ( & mut self , ssl_cert : & [ u8 ] ) -> & mut Config {
289+ self . ssl_cert = Some ( ssl_cert. into ( ) ) ;
290290 self
291291 }
292292
293- /// Gets the location of the client SSL certificate file .
294- pub fn get_ssl_cert ( & self ) -> Option < PathBuf > {
295- self . ssl_cert . clone ( )
293+ /// Gets the location of the client SSL certificate in PEM format .
294+ pub fn get_ssl_cert ( & self ) -> Option < & [ u8 ] > {
295+ self . ssl_cert . as_deref ( )
296296 }
297297
298- /// Sets the location of the secret key file used for the client certificate .
298+ /// Sets the client SSL key in PEM format .
299299 ///
300300 /// Defaults to `None`.
301- pub fn ssl_key ( & mut self , ssl_key : & str ) -> & mut Config {
302- self . ssl_key = Some ( PathBuf :: from ( ssl_key) ) ;
301+ pub fn ssl_key ( & mut self , ssl_key : & [ u8 ] ) -> & mut Config {
302+ self . ssl_key = Some ( ssl_key. into ( ) ) ;
303303 self
304304 }
305305
306- /// Gets the location of the secret key file used for the client certificate .
307- pub fn get_ssl_key ( & self ) -> Option < PathBuf > {
308- self . ssl_key . clone ( )
306+ /// Gets the client SSL key in PEM format .
307+ pub fn get_ssl_key ( & self ) -> Option < & [ u8 ] > {
308+ self . ssl_key . as_deref ( )
309309 }
310310
311311 /// Sets the SSL configuration.
@@ -321,17 +321,17 @@ impl Config {
321321 self . ssl_mode
322322 }
323323
324- /// Sets the location of SSL certificate authority (CA) certificate.
324+ /// Sets the SSL certificate authority (CA) certificate in PEM format .
325325 ///
326326 /// Defaults to `None`.
327- pub fn ssl_root_cert ( & mut self , ssl_root_cert : & str ) -> & mut Config {
328- self . ssl_root_cert = Some ( PathBuf :: from ( ssl_root_cert) ) ;
327+ pub fn ssl_root_cert ( & mut self , ssl_root_cert : & [ u8 ] ) -> & mut Config {
328+ self . ssl_root_cert = Some ( ssl_root_cert. into ( ) ) ;
329329 self
330330 }
331331
332- /// Gets the location of SSL certificate authority (CA) certificate.
333- pub fn get_ssl_root_cert ( & self ) -> Option < PathBuf > {
334- self . ssl_root_cert . clone ( )
332+ /// Gets the SSL certificate authority (CA) certificate in PEM format .
333+ pub fn get_ssl_root_cert ( & self ) -> Option < & [ u8 ] > {
334+ self . ssl_root_cert . as_deref ( )
335335 }
336336
337337 /// Adds a host to the configuration.
@@ -482,18 +482,22 @@ impl Config {
482482 "application_name" => {
483483 self . application_name ( value) ;
484484 }
485- "sslcert" => {
486- if std:: fs:: metadata ( & value) . is_err ( ) {
485+ "sslcert" => match std:: fs:: read ( & value) {
486+ Ok ( contents) => {
487+ self . ssl_cert ( & contents) ;
488+ }
489+ Err ( _) => {
487490 return Err ( Error :: config_parse ( Box :: new ( InvalidValue ( "sslcert" ) ) ) ) ;
488491 }
489- self . ssl_cert ( value) ;
490- }
491- "sslkey" => {
492- if std:: fs:: metadata ( & value) . is_err ( ) {
492+ } ,
493+ "sslkey" => match std:: fs:: read ( & value) {
494+ Ok ( contents) => {
495+ self . ssl_key ( & contents) ;
496+ }
497+ Err ( _) => {
493498 return Err ( Error :: config_parse ( Box :: new ( InvalidValue ( "sslkey" ) ) ) ) ;
494499 }
495- self . ssl_key ( value) ;
496- }
500+ } ,
497501 "sslmode" => {
498502 let mode = match value {
499503 "disable" => SslMode :: Disable ,
@@ -505,12 +509,14 @@ impl Config {
505509 } ;
506510 self . ssl_mode ( mode) ;
507511 }
508- "sslrootcert" => {
509- if std:: fs:: metadata ( & value) . is_err ( ) {
512+ "sslrootcert" => match std:: fs:: read ( & value) {
513+ Ok ( contents) => {
514+ self . ssl_root_cert ( & contents) ;
515+ }
516+ Err ( _) => {
510517 return Err ( Error :: config_parse ( Box :: new ( InvalidValue ( "sslrootcert" ) ) ) ) ;
511518 }
512- self . ssl_root_cert ( value) ;
513- }
519+ } ,
514520 "host" => {
515521 for host in value. split ( ',' ) {
516522 self . host ( host) ;
0 commit comments