MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / validate

Method validate

gateway/src/kv/https_client.rs:298–321  ·  view source on GitHub ↗
(&self, cert_der: &[u8])

Source from the content-addressed store, hash-verified

296
297impl CertValidator for AppIdValidator {
298 fn validate(&self, cert_der: &[u8]) -> Result<(), String> {
299 use ra_tls::traits::CertExt;
300
301 let (_, cert) = x509_parser::parse_x509_certificate(cert_der)
302 .map_err(|e| format!("failed to parse certificate: {e}"))?;
303
304 let peer_app_id = cert
305 .get_app_id()
306 .map_err(|e| format!("failed to get app_id: {e}"))?;
307
308 let Some(peer_app_id) = peer_app_id else {
309 return Err("peer certificate does not contain app_id".into());
310 };
311
312 if peer_app_id != self.expected_app_id {
313 return Err(format!(
314 "app_id mismatch: expected {}, got {}",
315 hex::encode(&self.expected_app_id),
316 hex::encode(&peer_app_id)
317 ));
318 }
319
320 Ok(())
321 }
322}

Callers 1

verify_server_certMethod · 0.45

Calls 1

get_app_idMethod · 0.80

Tested by

no test coverage detected