Skip to content

Commit d013c3d

Browse files
committed
fix(gateway): accept app-info peer identities
1 parent 3f41856 commit d013c3d

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

dstack/gateway/src/web_routes/wavekv_sync.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ use crate::{
1010
kv::{decode, encode},
1111
main_service::Proxy,
1212
};
13-
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
13+
use flate2::{Compression, read::GzDecoder, write::GzEncoder};
1414
use ra_tls::traits::CertExt;
1515
use rocket::{
16+
State,
1617
data::{Data, ToByteUnit},
1718
http::{ContentType, Status},
18-
mtls::{oid::Oid, Certificate},
19-
post, State,
19+
mtls::{Certificate, oid::Oid},
20+
post,
2021
};
2122
use std::io::{Read, Write};
2223
use tracing::warn;
@@ -82,13 +83,27 @@ fn verify_gateway_peer(state: &Proxy, cert: Option<Certificate<'_>>) -> Result<(
8283
return Err(Status::Unauthorized);
8384
};
8485

85-
let remote_app_id = RocketCert(&cert).get_app_id().map_err(|e| {
86-
warn!("WaveKV sync: failed to extract app_id from certificate: {e}");
87-
Status::Unauthorized
88-
})?;
86+
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+
});
89104

90105
let Some(remote_app_id) = remote_app_id else {
91-
warn!("WaveKV sync: certificate does not contain app_id");
106+
warn!("WaveKV sync: certificate does not contain app identity");
92107
return Err(Status::Unauthorized);
93108
};
94109

0 commit comments

Comments
 (0)