@@ -340,7 +340,6 @@ static MAX_TICKET_LIFETIME: u32 = 7 * 24 * 60 * 60;
340340static MAX_FRESHNESS_SKEW_MS : u32 = 60 * 1000 ;
341341
342342// --- Server types ---
343- #[ derive( Debug ) ]
344343pub struct ServerSessionValue {
345344 pub ( crate ) sni : Option < DnsName < ' static > > ,
346345 pub ( crate ) version : ProtocolVersion ,
@@ -355,6 +354,36 @@ pub struct ServerSessionValue {
355354 freshness : Option < bool > ,
356355}
357356
357+ impl fmt:: Debug for ServerSessionValue {
358+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
359+ let Self {
360+ sni,
361+ version,
362+ cipher_suite,
363+ master_secret : _,
364+ extended_ms,
365+ client_cert_chain,
366+ alpn,
367+ application_data,
368+ creation_time_sec,
369+ age_obfuscation_offset,
370+ freshness,
371+ } = self ;
372+ f. debug_struct ( "ServerSessionValue" )
373+ . field ( "sni" , sni)
374+ . field ( "version" , version)
375+ . field ( "cipher_suite" , cipher_suite)
376+ . field ( "extended_ms" , extended_ms)
377+ . field ( "client_cert_chain" , client_cert_chain)
378+ . field ( "alpn" , alpn)
379+ . field ( "application_data" , application_data)
380+ . field ( "creation_time_sec" , creation_time_sec)
381+ . field ( "age_obfuscation_offset" , age_obfuscation_offset)
382+ . field ( "freshness" , freshness)
383+ . finish_non_exhaustive ( )
384+ }
385+ }
386+
358387impl Codec < ' _ > for ServerSessionValue {
359388 fn encode ( & self , bytes : & mut Vec < u8 > ) {
360389 if let Some ( sni) = & self . sni {
@@ -497,19 +526,22 @@ mod tests {
497526 #[ cfg( feature = "std" ) ] // for UnixTime::now
498527 #[ test]
499528 fn serversessionvalue_is_debug ( ) {
500- use std:: { println, vec} ;
529+ use std:: { format , println, vec} ;
501530 let ssv = ServerSessionValue :: new (
502531 None ,
503532 ProtocolVersion :: TLSv1_3 ,
504533 CipherSuite :: TLS13_AES_128_GCM_SHA256 ,
505- & [ 1 , 2 , 3 ] ,
534+ & [ 0xa5 ; 48 ] ,
506535 None ,
507536 None ,
508537 vec ! [ 4 , 5 , 6 ] ,
509538 UnixTime :: now ( ) ,
510539 0x12345678 ,
511540 ) ;
512- println ! ( "{ssv:?}" ) ;
541+ let debug = format ! ( "{ssv:?}" ) ;
542+ println ! ( "{debug}" ) ;
543+ assert ! ( debug. contains( "application_data: 040506" ) ) ;
544+ assert ! ( !debug. contains( "a5a5" ) , "{debug}" ) ;
513545 }
514546
515547 #[ test]
0 commit comments