@@ -1630,14 +1630,13 @@ pub(crate) mod meta {
1630
1630
1631
1631
use anyhow:: Context ;
1632
1632
use anyhow:: Result ;
1633
- use rustls:: RootCertStore ;
1633
+ use tokio_rustls :: rustls:: RootCertStore ;
1634
1634
use tokio:: net:: TcpListener ;
1635
1635
use tokio:: net:: TcpStream ;
1636
1636
use tokio_rustls:: TlsAcceptor ;
1637
1637
use tokio_rustls:: TlsConnector ;
1638
1638
use tokio_rustls:: client:: TlsStream ;
1639
- use tokio_rustls:: rustls:: Certificate ;
1640
- use tokio_rustls:: rustls:: PrivateKey ;
1639
+ use tokio_rustls:: rustls:: pki_types:: { CertificateDer , PrivateKeyDer , ServerName } ;
1641
1640
1642
1641
use super :: * ;
1643
1642
use crate :: RemoteMessage ;
@@ -1674,7 +1673,7 @@ pub(crate) mod meta {
1674
1673
let trust_anchors = ca_certs. iter ( ) . filter_map ( |cert| {
1675
1674
webpki:: TrustAnchor :: try_from_cert_der ( & cert[ ..] )
1676
1675
. map ( |ta| {
1677
- rustls:: OwnedTrustAnchor :: from_subject_spki_name_constraints (
1676
+ tokio_rustls :: rustls:: OwnedTrustAnchor :: from_subject_spki_name_constraints (
1678
1677
ta. subject ,
1679
1678
ta. spki ,
1680
1679
ta. name_constraints ,
@@ -1693,7 +1692,7 @@ pub(crate) mod meta {
1693
1692
File :: open ( server_cert_path) . context ( "failed to open {server_cert_path}" ) ?,
1694
1693
) ) ?
1695
1694
. into_iter ( )
1696
- . map ( Certificate )
1695
+ . map ( CertificateDer :: from )
1697
1696
. collect ( ) ;
1698
1697
// certs are good here
1699
1698
let server_key_path = DEFAULT_SERVER_PEM_PATH ;
@@ -1712,22 +1711,22 @@ pub(crate) mod meta {
1712
1711
} ;
1713
1712
} ;
1714
1713
1715
- let config = rustls:: ServerConfig :: builder ( ) . with_safe_defaults ( ) ;
1714
+ let config = tokio_rustls :: rustls:: ServerConfig :: builder ( ) . with_safe_defaults ( ) ;
1716
1715
1717
1716
let config = if enforce_client_tls {
1718
- let client_cert_verifier = Arc :: new ( rustls:: server:: AllowAnyAuthenticatedClient :: new (
1717
+ let client_cert_verifier = Arc :: new ( tokio_rustls :: rustls:: server:: AllowAnyAuthenticatedClient :: new (
1719
1718
root_cert_store ( ) ?,
1720
1719
) ) ;
1721
1720
config. with_client_cert_verifier ( client_cert_verifier)
1722
1721
} else {
1723
1722
config. with_no_client_auth ( )
1724
1723
}
1725
- . with_single_cert ( certs, PrivateKey ( key) ) ?;
1724
+ . with_single_cert ( certs, PrivateKeyDer :: from ( key) ) ?;
1726
1725
1727
1726
Ok ( TlsAcceptor :: from ( Arc :: new ( config) ) )
1728
1727
}
1729
1728
1730
- fn load_client_pem ( ) -> Result < Option < ( Vec < rustls :: Certificate > , rustls :: PrivateKey ) > > {
1729
+ fn load_client_pem ( ) -> Result < Option < ( Vec < CertificateDer < ' static > > , PrivateKeyDer < ' static > ) > > {
1731
1730
let Some ( cert_path) = std:: env:: var_os ( THRIFT_TLS_CL_CERT_PATH_ENV ) else {
1732
1731
return Ok ( None ) ;
1733
1732
} ;
@@ -1738,7 +1737,7 @@ pub(crate) mod meta {
1738
1737
File :: open ( cert_path) . context ( "failed to open {cert_path}" ) ?,
1739
1738
) ) ?
1740
1739
. into_iter ( )
1741
- . map ( rustls :: Certificate )
1740
+ . map ( CertificateDer :: from )
1742
1741
. collect ( ) ;
1743
1742
let mut key_reader =
1744
1743
BufReader :: new ( File :: open ( key_path) . context ( "failed to open {key_path}" ) ?) ;
@@ -1752,13 +1751,13 @@ pub(crate) mod meta {
1752
1751
} ;
1753
1752
} ;
1754
1753
// Certs are verified to be good here.
1755
- Ok ( Some ( ( certs, rustls :: PrivateKey ( key) ) ) )
1754
+ Ok ( Some ( ( certs, PrivateKeyDer :: from ( key) ) ) )
1756
1755
}
1757
1756
1758
1757
/// Creates a TLS connector by looking for necessary certs and keys in a Meta server environment.
1759
1758
fn tls_connector ( ) -> Result < TlsConnector > {
1760
1759
// TODO (T208180540): try to simplify the logic here.
1761
- let config = rustls:: ClientConfig :: builder ( )
1760
+ let config = tokio_rustls :: rustls:: ClientConfig :: builder ( )
1762
1761
. with_safe_defaults ( )
1763
1762
. with_root_certificates ( root_cert_store ( ) ?) ;
1764
1763
let result = load_client_pem ( ) ?;
@@ -1772,9 +1771,9 @@ pub(crate) mod meta {
1772
1771
Ok ( TlsConnector :: from ( Arc :: new ( config) ) )
1773
1772
}
1774
1773
1775
- fn tls_connector_config ( peer_host_name : & str ) -> Result < ( TlsConnector , rustls :: ServerName ) > {
1774
+ fn tls_connector_config ( peer_host_name : & str ) -> Result < ( TlsConnector , ServerName < ' static > ) > {
1776
1775
let connector = tls_connector ( ) ?;
1777
- let server_name = rustls :: ServerName :: try_from ( peer_host_name) ?;
1776
+ let server_name = ServerName :: try_from ( peer_host_name. to_string ( ) ) ?;
1778
1777
Ok ( ( connector, server_name) )
1779
1778
}
1780
1779
0 commit comments