@@ -21,7 +21,7 @@ use rustls::{
2121 pki_types:: { CertificateDer , PrivateKeyDer , ServerName } ,
2222 server:: { ProducesTickets , WebPkiClientVerifier } ,
2323 version:: TLS13 ,
24- ClientConfig , ClientConnection , Connection ,
24+ ClientConfig , ClientConnection , CommonState , Connection , HandshakeKind ,
2525 ProtocolVersion :: TLSv1_3 ,
2626 RootCertStore , ServerConfig , ServerConnection ,
2727} ;
@@ -63,6 +63,13 @@ impl RustlsConnection {
6363 } ,
6464 }
6565 }
66+
67+ fn connection_common ( & self ) -> & CommonState {
68+ match & self . connection {
69+ Connection :: Client ( client_connection) => client_connection,
70+ Connection :: Server ( server_connection) => server_connection,
71+ }
72+ }
6673}
6774
6875#[ derive( Debug ) ]
@@ -310,11 +317,15 @@ impl TlsInfo for RustlsConnection {
310317 }
311318
312319 fn resumed_connection ( & self ) -> bool {
313- if let rustls:: Connection :: Server ( s) = & self . connection {
314- s. received_resumption_data ( ) . is_some ( )
315- } else {
316- panic ! ( "rustls connection resumption status must be check on the server side" ) ;
317- }
320+ self . connection_common ( ) . handshake_kind ( ) . unwrap ( ) == HandshakeKind :: Resumed
321+ }
322+
323+ fn mutual_auth ( & self ) -> bool {
324+ assert ! ( matches!( self . connection, Connection :: Server ( _) ) ) ;
325+ //> For servers, this is the certificate chain or the raw public key of
326+ //> the client, if client authentication was completed.
327+ //> https://docs.rs/rustls/latest/rustls/struct.CommonState.html#method.peer_certificates
328+ self . connection_common ( ) . peer_certificates ( ) . is_some ( )
318329 }
319330}
320331
0 commit comments