@@ -32,7 +32,7 @@ use percent_encoding::percent_decode;
32
32
#[ cfg( all( feature = "gssapi" , feature = "tls-rustls" ) ) ]
33
33
use ring:: digest:: { self , digest, Algorithm } ;
34
34
#[ cfg( feature = "tls-rustls" ) ]
35
- use rustls:: { Certificate , ClientConfig , RootCertStore , ServerName } ;
35
+ use rustls:: { pki_types :: CertificateDer , pki_types :: ServerName , ClientConfig , RootCertStore } ;
36
36
use tokio:: io:: { self , AsyncRead , AsyncWrite , AsyncWriteExt , ReadBuf } ;
37
37
use tokio:: net:: TcpStream ;
38
38
#[ cfg( unix) ]
@@ -61,20 +61,54 @@ enum ConnType {
61
61
}
62
62
63
63
#[ cfg( feature = "tls-rustls" ) ]
64
+ #[ derive( Debug ) ]
64
65
struct NoCertVerification ;
65
66
66
67
#[ cfg( feature = "tls-rustls" ) ]
67
- impl rustls:: client:: ServerCertVerifier for NoCertVerification {
68
+ impl rustls:: client:: danger :: ServerCertVerifier for NoCertVerification {
68
69
fn verify_server_cert (
69
70
& self ,
70
- _: & Certificate ,
71
- _: & [ Certificate ] ,
71
+ _: & CertificateDer ,
72
+ _: & [ CertificateDer ] ,
72
73
_: & ServerName ,
73
- _: & mut dyn Iterator < Item = & [ u8 ] > ,
74
74
_: & [ u8 ] ,
75
- _: std:: time:: SystemTime ,
76
- ) -> std:: result:: Result < rustls:: client:: ServerCertVerified , rustls:: Error > {
77
- Ok ( rustls:: client:: ServerCertVerified :: assertion ( ) )
75
+ _: rustls:: pki_types:: UnixTime ,
76
+ ) -> std:: result:: Result < rustls:: client:: danger:: ServerCertVerified , rustls:: Error > {
77
+ Ok ( rustls:: client:: danger:: ServerCertVerified :: assertion ( ) )
78
+ }
79
+
80
+ fn verify_tls12_signature (
81
+ & self ,
82
+ _: & [ u8 ] ,
83
+ _: & CertificateDer ,
84
+ _: & rustls:: DigitallySignedStruct ,
85
+ ) -> std:: result:: Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
86
+ Ok ( rustls:: client:: danger:: HandshakeSignatureValid :: assertion ( ) )
87
+ }
88
+
89
+ fn verify_tls13_signature (
90
+ & self ,
91
+ _: & [ u8 ] ,
92
+ _: & CertificateDer ,
93
+ _: & rustls:: DigitallySignedStruct ,
94
+ ) -> std:: result:: Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
95
+ Ok ( rustls:: client:: danger:: HandshakeSignatureValid :: assertion ( ) )
96
+ }
97
+
98
+ fn supported_verify_schemes ( & self ) -> Vec < rustls:: SignatureScheme > {
99
+ vec ! [
100
+ rustls:: SignatureScheme :: RSA_PKCS1_SHA1 ,
101
+ rustls:: SignatureScheme :: ECDSA_SHA1_Legacy ,
102
+ rustls:: SignatureScheme :: RSA_PKCS1_SHA256 ,
103
+ rustls:: SignatureScheme :: ECDSA_NISTP256_SHA256 ,
104
+ rustls:: SignatureScheme :: RSA_PKCS1_SHA384 ,
105
+ rustls:: SignatureScheme :: ECDSA_NISTP384_SHA384 ,
106
+ rustls:: SignatureScheme :: RSA_PKCS1_SHA512 ,
107
+ rustls:: SignatureScheme :: ECDSA_NISTP521_SHA512 ,
108
+ rustls:: SignatureScheme :: RSA_PSS_SHA256 ,
109
+ rustls:: SignatureScheme :: RSA_PSS_SHA384 ,
110
+ rustls:: SignatureScheme :: RSA_PSS_SHA512 ,
111
+ ]
78
112
}
79
113
}
80
114
@@ -83,7 +117,7 @@ lazy_static! {
83
117
static ref CACERTS : RootCertStore = {
84
118
let mut store = RootCertStore :: empty( ) ;
85
119
for cert in rustls_native_certs:: load_native_certs( ) . unwrap_or_else( |_| vec![ ] ) {
86
- if let Ok ( _) = store. add( & Certificate ( cert. 0 ) ) { }
120
+ if let Ok ( _) = store. add( cert) { }
87
121
}
88
122
store
89
123
} ;
@@ -477,17 +511,19 @@ impl LdapConnAsync {
477
511
} ;
478
512
TokioTlsConnector :: from ( config)
479
513
. connect (
480
- ServerName :: try_from ( hostname) . or_else ( |e| {
481
- if no_tls_verify {
482
- if let Ok ( _addr) = IpAddr :: from_str ( hostname) {
483
- ServerName :: try_from ( "_irrelevant" )
514
+ ServerName :: try_from ( hostname)
515
+ . map ( |sn| sn. to_owned ( ) )
516
+ . or_else ( |e| {
517
+ if no_tls_verify {
518
+ if let Ok ( _addr) = IpAddr :: from_str ( hostname) {
519
+ ServerName :: try_from ( "_irrelevant" )
520
+ } else {
521
+ Err ( e)
522
+ }
484
523
} else {
485
524
Err ( e)
486
525
}
487
- } else {
488
- Err ( e)
489
- }
490
- } ) ?,
526
+ } ) ?,
491
527
stream,
492
528
)
493
529
. await
@@ -497,7 +533,6 @@ impl LdapConnAsync {
497
533
#[ cfg( feature = "tls-rustls" ) ]
498
534
fn create_config ( settings : & LdapConnSettings ) -> Arc < ClientConfig > {
499
535
let mut config = ClientConfig :: builder ( )
500
- . with_safe_defaults ( )
501
536
. with_root_certificates ( CACERTS . clone ( ) )
502
537
. with_no_client_auth ( ) ;
503
538
if settings. no_tls_verify {
@@ -635,7 +670,7 @@ impl LdapConnAsync {
635
670
if certs. is_empty ( ) {
636
671
Ok ( None )
637
672
} else {
638
- Ok ( Some ( certs[ 0 ] . clone ( ) . 0 ) )
673
+ Ok ( Some ( certs[ 0 ] . to_vec ( ) ) )
639
674
}
640
675
}
641
676
}
0 commit comments