Skip to content

Commit ddacec1

Browse files
committed
fix(gateway): decode app-info peer identity
1 parent d013c3d commit ddacec1

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

dstack/gateway/src/web_routes/wavekv_sync.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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};
1414
use ra_tls::traits::CertExt;
1515
use 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
};
2221
use std::io::{Read, Write};
2322
use 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

Comments
 (0)