@@ -440,7 +440,7 @@ fn is_benign_tls_handshake_failure(error: &std::io::Error) -> bool {
440440 )
441441}
442442
443- const METRICS_TLS_HANDSHAKE_WARNING_INTERVAL : Duration = Duration :: from_secs ( 60 ) ;
443+ const METRICS_TLS_HANDSHAKE_WARNING_INTERVAL : Duration = Duration :: from_mins ( 1 ) ;
444444
445445#[ derive( Default ) ]
446446struct MetricsTlsHandshakeLogState {
@@ -2486,8 +2486,9 @@ mod tests {
24862486 proto:: { HealthRequest , open_shell_client:: OpenShellClient } ,
24872487 } ;
24882488 use rcgen:: { CertificateParams , KeyUsagePurpose } ;
2489- use std:: fs:: { self , File } ;
2490- use std:: io:: { BufReader , Error , ErrorKind } ;
2489+ use rustls_pki_types:: { CertificateDer , PrivateKeyDer , pem:: PemObject } ;
2490+ use std:: fs;
2491+ use std:: io:: { Error , ErrorKind } ;
24912492 use std:: net:: SocketAddr ;
24922493 use std:: path:: { Path , PathBuf } ;
24932494 use std:: sync:: {
@@ -2520,22 +2521,21 @@ mod tests {
25202521
25212522 fn test_tls_connector ( ca_path : & Path , client_auth : Option < ( & Path , & Path ) > ) -> TlsConnector {
25222523 let mut roots = rustls:: RootCertStore :: empty ( ) ;
2523- let file = File :: open ( ca_path) . expect ( "failed to open test CA certificate" ) ;
2524- for certificate in rustls_pemfile:: certs ( & mut BufReader :: new ( file) ) {
2524+ let certificates =
2525+ CertificateDer :: pem_file_iter ( ca_path) . expect ( "failed to open test CA certificate" ) ;
2526+ for certificate in certificates {
25252527 roots
25262528 . add ( certificate. expect ( "failed to parse test CA certificate" ) )
25272529 . expect ( "failed to add test CA certificate" ) ;
25282530 }
25292531
25302532 let config = if let Some ( ( cert_path, key_path) ) = client_auth {
2531- let cert_file = File :: open ( cert_path) . expect ( "failed to open test client certificate" ) ;
2532- let cert_chain = rustls_pemfile :: certs ( & mut BufReader :: new ( cert_file ) )
2533+ let cert_chain = CertificateDer :: pem_file_iter ( cert_path)
2534+ . expect ( "failed to open test client certificate" )
25332535 . collect :: < Result < Vec < _ > , _ > > ( )
25342536 . expect ( "failed to parse test client certificate" ) ;
2535- let key_file = File :: open ( key_path) . expect ( "failed to open test client key" ) ;
2536- let private_key = rustls_pemfile:: private_key ( & mut BufReader :: new ( key_file) )
2537- . expect ( "failed to parse test client key" )
2538- . expect ( "test client key is missing" ) ;
2537+ let private_key =
2538+ PrivateKeyDer :: from_pem_file ( key_path) . expect ( "failed to parse test client key" ) ;
25392539
25402540 Arc :: new (
25412541 rustls:: ClientConfig :: builder ( )
@@ -3118,7 +3118,7 @@ mod tests {
31183118 . with_filter ( tracing_subscriber:: filter:: LevelFilter :: DEBUG ) ,
31193119 ) ;
31203120 let _traced = crate :: otel_tracing:: test_exporter:: install_scoped ( subscriber) ;
3121- let limiter = MetricsTlsHandshakeLogLimiter :: new ( Duration :: from_secs ( 60 ) ) ;
3121+ let limiter = MetricsTlsHandshakeLogLimiter :: new ( Duration :: from_mins ( 1 ) ) ;
31223122
31233123 log_metrics_tls_handshake_rejection (
31243124 & limiter,
@@ -3146,14 +3146,14 @@ mod tests {
31463146
31473147 #[ test]
31483148 fn metrics_tls_handshake_warnings_are_rate_limited ( ) {
3149- let limiter = MetricsTlsHandshakeLogLimiter :: new ( Duration :: from_secs ( 60 ) ) ;
3149+ let limiter = MetricsTlsHandshakeLogLimiter :: new ( Duration :: from_mins ( 1 ) ) ;
31503150 let start = Instant :: now ( ) ;
31513151
31523152 assert_eq ! ( limiter. record( start) , Some ( 0 ) ) ;
31533153 assert_eq ! ( limiter. record( start + Duration :: from_secs( 1 ) ) , None ) ;
31543154 assert_eq ! ( limiter. record( start + Duration :: from_secs( 2 ) ) , None ) ;
31553155 assert_eq ! (
3156- limiter. record( start + Duration :: from_secs ( 60 ) ) ,
3156+ limiter. record( start + Duration :: from_mins ( 1 ) ) ,
31573157 Some ( 2 ) ,
31583158 "the next warning reports the rejected handshakes suppressed during the interval"
31593159 ) ;
@@ -3172,7 +3172,7 @@ mod tests {
31723172 . with_filter ( tracing_subscriber:: filter:: LevelFilter :: DEBUG ) ,
31733173 ) ;
31743174 let _traced = crate :: otel_tracing:: test_exporter:: install_scoped ( subscriber) ;
3175- let limiters = MetricsTlsHandshakeLogLimiters :: new ( Duration :: from_secs ( 60 ) ) ;
3175+ let limiters = MetricsTlsHandshakeLogLimiters :: new ( Duration :: from_mins ( 1 ) ) ;
31763176 let client = "192.0.2.10:443" . parse ( ) . expect ( "valid test client address" ) ;
31773177
31783178 // A rejected handshake warns once and suppresses further rejections
0 commit comments