@@ -10,6 +10,7 @@ use std::{
1010 fs:: File ,
1111 hash:: { Hash , Hasher } ,
1212 io:: { BufReader , Seek , SeekFrom } ,
13+ path:: PathBuf ,
1314 str:: FromStr ,
1415 sync:: Arc ,
1516 time:: Duration ,
@@ -564,13 +565,13 @@ pub struct TlsOptions {
564565 /// The path to the CA file that the [`Client`](../struct.Client.html) should use for TLS. If
565566 /// none is specified, then the driver will use the Mozilla root certificates from the
566567 /// `webpki-roots` crate.
567- pub ca_file_path : Option < String > ,
568+ pub ca_file_path : Option < PathBuf > ,
568569
569570 /// The path to the certificate file that the [`Client`](../struct.Client.html) should present
570571 /// to the server to verify its identify. If none is specified, then the
571572 /// [`Client`](../struct.Client.html) will not attempt to verify its identity to the
572573 /// server.
573- pub cert_key_file_path : Option < String > ,
574+ pub cert_key_file_path : Option < PathBuf > ,
574575}
575576
576577struct NoCertVerifier { }
@@ -603,7 +604,10 @@ impl TlsOptions {
603604 store
604605 . add_pem_file ( & mut BufReader :: new ( File :: open ( & path) ?) )
605606 . map_err ( |_| ErrorKind :: InvalidTlsConfig {
606- message : format ! ( "Unable to parse PEM-encoded root certificate from {}" , path) ,
607+ message : format ! (
608+ "Unable to parse PEM-encoded root certificate from {}" ,
609+ path. display( )
610+ ) ,
607611 } ) ?;
608612 } else {
609613 store. add_server_trust_anchors ( & TLS_SERVER_ROOTS ) ;
@@ -619,7 +623,7 @@ impl TlsOptions {
619623 return Err ( ErrorKind :: InvalidTlsConfig {
620624 message : format ! (
621625 "Unable to parse PEM-encoded client certificate from {}" ,
622- path
626+ path. display ( )
623627 ) ,
624628 }
625629 . into ( ) )
@@ -631,7 +635,10 @@ impl TlsOptions {
631635 Ok ( key) => key,
632636 Err ( ( ) ) => {
633637 return Err ( ErrorKind :: InvalidTlsConfig {
634- message : format ! ( "Unable to parse PEM-encoded RSA key from {}" , path) ,
638+ message : format ! (
639+ "Unable to parse PEM-encoded RSA key from {}" ,
640+ path. display( )
641+ ) ,
635642 }
636643 . into ( ) )
637644 }
@@ -1623,13 +1630,11 @@ impl ClientOptionsParser {
16231630 . into ( ) ) ;
16241631 }
16251632 Some ( Tls :: Enabled ( ref mut options) ) => {
1626- options. ca_file_path = Some ( value. to_string ( ) ) ;
1633+ options. ca_file_path = Some ( value. into ( ) ) ;
16271634 }
16281635 None => {
16291636 self . tls = Some ( Tls :: Enabled (
1630- TlsOptions :: builder ( )
1631- . ca_file_path ( value. to_string ( ) )
1632- . build ( ) ,
1637+ TlsOptions :: builder ( ) . ca_file_path ( value. into ( ) ) . build ( ) ,
16331638 ) )
16341639 }
16351640 } ,
@@ -1641,12 +1646,12 @@ impl ClientOptionsParser {
16411646 . into ( ) ) ;
16421647 }
16431648 Some ( Tls :: Enabled ( ref mut options) ) => {
1644- options. cert_key_file_path = Some ( value. to_string ( ) ) ;
1649+ options. cert_key_file_path = Some ( value. into ( ) ) ;
16451650 }
16461651 None => {
16471652 self . tls = Some ( Tls :: Enabled (
16481653 TlsOptions :: builder ( )
1649- . cert_key_file_path ( value. to_string ( ) )
1654+ . cert_key_file_path ( value. into ( ) )
16501655 . build ( ) ,
16511656 ) )
16521657 }
0 commit comments