@@ -10,6 +10,7 @@ use std::{
10
10
fs:: File ,
11
11
hash:: { Hash , Hasher } ,
12
12
io:: { BufReader , Seek , SeekFrom } ,
13
+ path:: PathBuf ,
13
14
str:: FromStr ,
14
15
sync:: Arc ,
15
16
time:: Duration ,
@@ -564,13 +565,13 @@ pub struct TlsOptions {
564
565
/// The path to the CA file that the [`Client`](../struct.Client.html) should use for TLS. If
565
566
/// none is specified, then the driver will use the Mozilla root certificates from the
566
567
/// `webpki-roots` crate.
567
- pub ca_file_path : Option < String > ,
568
+ pub ca_file_path : Option < PathBuf > ,
568
569
569
570
/// The path to the certificate file that the [`Client`](../struct.Client.html) should present
570
571
/// to the server to verify its identify. If none is specified, then the
571
572
/// [`Client`](../struct.Client.html) will not attempt to verify its identity to the
572
573
/// server.
573
- pub cert_key_file_path : Option < String > ,
574
+ pub cert_key_file_path : Option < PathBuf > ,
574
575
}
575
576
576
577
struct NoCertVerifier { }
@@ -603,7 +604,10 @@ impl TlsOptions {
603
604
store
604
605
. add_pem_file ( & mut BufReader :: new ( File :: open ( & path) ?) )
605
606
. 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
+ ) ,
607
611
} ) ?;
608
612
} else {
609
613
store. add_server_trust_anchors ( & TLS_SERVER_ROOTS ) ;
@@ -619,7 +623,7 @@ impl TlsOptions {
619
623
return Err ( ErrorKind :: InvalidTlsConfig {
620
624
message : format ! (
621
625
"Unable to parse PEM-encoded client certificate from {}" ,
622
- path
626
+ path. display ( )
623
627
) ,
624
628
}
625
629
. into ( ) )
@@ -631,7 +635,10 @@ impl TlsOptions {
631
635
Ok ( key) => key,
632
636
Err ( ( ) ) => {
633
637
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
+ ) ,
635
642
}
636
643
. into ( ) )
637
644
}
@@ -1623,13 +1630,11 @@ impl ClientOptionsParser {
1623
1630
. into ( ) ) ;
1624
1631
}
1625
1632
Some ( Tls :: Enabled ( ref mut options) ) => {
1626
- options. ca_file_path = Some ( value. to_string ( ) ) ;
1633
+ options. ca_file_path = Some ( value. into ( ) ) ;
1627
1634
}
1628
1635
None => {
1629
1636
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 ( ) ,
1633
1638
) )
1634
1639
}
1635
1640
} ,
@@ -1641,12 +1646,12 @@ impl ClientOptionsParser {
1641
1646
. into ( ) ) ;
1642
1647
}
1643
1648
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 ( ) ) ;
1645
1650
}
1646
1651
None => {
1647
1652
self . tls = Some ( Tls :: Enabled (
1648
1653
TlsOptions :: builder ( )
1649
- . cert_key_file_path ( value. to_string ( ) )
1654
+ . cert_key_file_path ( value. into ( ) )
1650
1655
. build ( ) ,
1651
1656
) )
1652
1657
}
0 commit comments