11use std:: sync:: Arc ;
22
3- use quinn:: crypto:: rustls:: { QuicClientConfig , QuicServerConfig } ;
4- use rustls:: {
5- SignatureScheme ,
6- client:: danger:: { HandshakeSignatureValid , ServerCertVerified , ServerCertVerifier } ,
7- pki_types:: { CertificateDer , PrivateKeyDer } ,
3+ use quinn:: {
4+ crypto:: rustls:: { QuicClientConfig , QuicServerConfig } ,
5+ rustls:: {
6+ self , SignatureScheme ,
7+ client:: danger:: { ServerCertVerified , ServerCertVerifier } ,
8+ pki_types:: { CertificateDer , PrivateKeyDer } ,
9+ } ,
810} ;
911
1012use crate :: quic:: ALPN_PROTOCOL ;
@@ -15,7 +17,7 @@ pub(crate) struct SkipServerVerification(Arc<rustls::crypto::CryptoProvider>);
1517
1618impl SkipServerVerification {
1719 fn new ( ) -> Arc < Self > {
18- Arc :: new ( Self ( Arc :: new ( rustls:: crypto:: aws_lc_rs :: default_provider ( ) ) ) )
20+ Arc :: new ( Self ( Arc :: new ( rustls:: crypto:: ring :: default_provider ( ) ) ) )
1921 }
2022}
2123
@@ -28,36 +30,54 @@ impl ServerCertVerifier for SkipServerVerification {
2830 _ocsp_response : & [ u8 ] ,
2931 _now : rustls:: pki_types:: UnixTime ,
3032 ) -> Result < rustls:: client:: danger:: ServerCertVerified , rustls:: Error > {
33+ tracing:: debug!( target = "quic.tls" , "Skipping server verification" ) ;
3134 Ok ( ServerCertVerified :: assertion ( ) )
3235 }
3336
3437 fn verify_tls12_signature (
3538 & self ,
36- _message : & [ u8 ] ,
37- _cert : & rustls:: pki_types:: CertificateDer < ' _ > ,
38- _dss : & rustls:: DigitallySignedStruct ,
39+ message : & [ u8 ] ,
40+ cert : & rustls:: pki_types:: CertificateDer < ' _ > ,
41+ dss : & rustls:: DigitallySignedStruct ,
3942 ) -> Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
40- Ok ( HandshakeSignatureValid :: assertion ( ) )
43+ tracing:: debug!( target = "quic.tls" , "Verifying TLS 1.2 signature" ) ;
44+ rustls:: crypto:: verify_tls12_signature (
45+ message,
46+ cert,
47+ dss,
48+ & self . 0 . signature_verification_algorithms ,
49+ )
4150 }
4251
4352 fn verify_tls13_signature (
4453 & self ,
45- _message : & [ u8 ] ,
46- _cert : & rustls:: pki_types:: CertificateDer < ' _ > ,
47- _dss : & rustls:: DigitallySignedStruct ,
54+ message : & [ u8 ] ,
55+ cert : & rustls:: pki_types:: CertificateDer < ' _ > ,
56+ dss : & rustls:: DigitallySignedStruct ,
4857 ) -> Result < rustls:: client:: danger:: HandshakeSignatureValid , rustls:: Error > {
49- Ok ( HandshakeSignatureValid :: assertion ( ) )
58+ tracing:: debug!( target = "quic.tls" , "Verifying TLS 1.3 signature" ) ;
59+ rustls:: crypto:: verify_tls13_signature (
60+ message,
61+ cert,
62+ dss,
63+ & self . 0 . signature_verification_algorithms ,
64+ )
5065 }
5166
5267 fn supported_verify_schemes ( & self ) -> Vec < SignatureScheme > {
68+ tracing:: debug!(
69+ target = "quic.tls" ,
70+ "Supported verify schemes: {:?}" ,
71+ self . 0 . signature_verification_algorithms. supported_schemes( )
72+ ) ;
5373 self . 0 . signature_verification_algorithms . supported_schemes ( )
5474 }
5575}
5676
5777/// Returns a TLS configuration that skips all server verification and doesn't do any client
5878/// authentication, with the correct ALPN protocol.
5979pub ( crate ) fn unsafe_client_config ( ) -> QuicClientConfig {
60- let provider = Arc :: new ( rustls:: crypto:: aws_lc_rs :: default_provider ( ) ) ;
80+ let provider = Arc :: new ( rustls:: crypto:: ring :: default_provider ( ) ) ;
6181
6282 let mut rustls_config = rustls:: ClientConfig :: builder_with_provider ( provider)
6383 . with_protocol_versions ( & [ & rustls:: version:: TLS13 ] )
@@ -76,7 +96,7 @@ pub(crate) fn unsafe_client_config() -> QuicClientConfig {
7696/// the correct ALPN protocol.
7797pub ( crate ) fn tls_server_config ( ) -> QuicServerConfig {
7898 let ( cert_chain, key_der) = self_signed_certificate ( ) ;
79- let provider = Arc :: new ( rustls:: crypto:: aws_lc_rs :: default_provider ( ) ) ;
99+ let provider = Arc :: new ( rustls:: crypto:: ring :: default_provider ( ) ) ;
80100
81101 let mut rustls_config = rustls:: ServerConfig :: builder_with_provider ( provider)
82102 . with_protocol_versions ( & [ & rustls:: version:: TLS13 ] )
0 commit comments