@@ -10,14 +10,13 @@ use crate::{
1010 kv:: { decode, encode} ,
1111 main_service:: Proxy ,
1212} ;
13- use flate2:: { Compression , read:: GzDecoder , write:: GzEncoder } ;
13+ use flate2:: { read:: GzDecoder , write:: GzEncoder , Compression } ;
1414use ra_tls:: traits:: CertExt ;
1515use rocket:: {
16- State ,
1716 data:: { Data , ToByteUnit } ,
1817 http:: { ContentType , Status } ,
19- mtls:: { Certificate , oid:: Oid } ,
20- post,
18+ mtls:: { oid:: Oid , Certificate } ,
19+ post, State ,
2120} ;
2221use std:: io:: { Read , Write } ;
2322use tracing:: warn;
@@ -84,23 +83,19 @@ fn verify_gateway_peer(state: &Proxy, cert: Option<Certificate<'_>>) -> Result<(
8483 } ;
8584
8685 let cert = RocketCert ( & cert) ;
87- let remote_app_id = cert
88- . get_app_id ( )
89- . map_err ( |e| {
90- warn ! ( "WaveKV sync: failed to extract app_id from certificate: {e}" ) ;
91- Status :: Unauthorized
92- } ) ?
93- . or_else ( || {
94- cert. get_app_info ( )
95- . map_err ( |e| {
96- warn ! ( "WaveKV sync: failed to extract app_info from certificate: {e}" ) ;
97- Status :: Unauthorized
98- } )
99- . transpose ( )
100- . ok ( )
101- . flatten ( )
102- . map ( |info| info. app_id )
103- } ) ;
86+ let remote_app_id = match cert. get_app_id ( ) . map_err ( |e| {
87+ warn ! ( "WaveKV sync: failed to extract app_id from certificate: {e}" ) ;
88+ Status :: Unauthorized
89+ } ) ? {
90+ Some ( app_id) => Some ( app_id) ,
91+ None => cert
92+ . get_app_info ( )
93+ . map_err ( |e| {
94+ warn ! ( "WaveKV sync: failed to extract app_info from certificate: {e}" ) ;
95+ Status :: Unauthorized
96+ } ) ?
97+ . map ( |info| info. app_id ) ,
98+ } ;
10499
105100 let Some ( remote_app_id) = remote_app_id else {
106101 warn ! ( "WaveKV sync: certificate does not contain app identity" ) ;
0 commit comments