@@ -12,6 +12,8 @@ use rustls::{
1212 pki_types:: { CertificateDer , PrivateKeyDer , ServerName } ,
1313 quic:: { Connection , HeaderProtectionKey , KeyChange , PacketKey , Secrets , Suite , Version } ,
1414} ;
15+ #[ cfg( feature = "platform-verifier" ) ]
16+ use rustls_platform_verifier:: BuilderVerifierExt ;
1517
1618use crate :: {
1719 ConnectError , ConnectionId , Side , TransportError , TransportErrorCode ,
@@ -281,6 +283,24 @@ pub struct QuicClientConfig {
281283}
282284
283285impl QuicClientConfig {
286+ #[ cfg( feature = "platform-verifier" ) ]
287+ pub ( crate ) fn with_platform_verifier ( ) -> Result < Self , Error > {
288+ // Keep in sync with `inner()` below
289+ let mut inner = rustls:: ClientConfig :: builder_with_provider ( configured_provider ( ) )
290+ . with_protocol_versions ( & [ & rustls:: version:: TLS13 ] )
291+ . unwrap ( ) // The default providers support TLS 1.3
292+ . with_platform_verifier ( ) ?
293+ . with_no_client_auth ( ) ;
294+
295+ inner. enable_early_data = true ;
296+ Ok ( Self {
297+ // We're confident that the *ring* default provider contains TLS13_AES_128_GCM_SHA256
298+ initial : initial_suite_from_provider ( inner. crypto_provider ( ) )
299+ . expect ( "no initial cipher suite found" ) ,
300+ inner : Arc :: new ( inner) ,
301+ } )
302+ }
303+
284304 /// Initialize a sane QUIC-compatible TLS client configuration
285305 ///
286306 /// QUIC requires that TLS 1.3 be enabled. Advanced users can use any [`rustls::ClientConfig`] that
@@ -309,6 +329,7 @@ impl QuicClientConfig {
309329 }
310330
311331 pub ( crate ) fn inner ( verifier : Arc < dyn ServerCertVerifier > ) -> rustls:: ClientConfig {
332+ // Keep in sync with `with_platform_verifier()` above
312333 let mut config = rustls:: ClientConfig :: builder_with_provider ( configured_provider ( ) )
313334 . with_protocol_versions ( & [ & rustls:: version:: TLS13 ] )
314335 . unwrap ( ) // The default providers support TLS 1.3
0 commit comments