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

Function handle_prpc_impl

ra-rpc/src/rocket_helper.rs:504–580  ·  view source on GitHub ↗
(
    args: PrpcHandler<'_, '_, S>,
)

Source from the content-addressed store, hash-verified

502}
503
504pub async fn handle_prpc_impl<S, Call: RpcCall<S>>(
505 args: PrpcHandler<'_, '_, S>,
506) -> Result<RpcResponse> {
507 let PrpcHandler {
508 state,
509 request,
510 method,
511 method_trim_prefix,
512 data,
513 } = args;
514 let method = method.trim_start_matches(method_trim_prefix.unwrap_or_default());
515 let info = request
516 .certificate
517 .as_ref()
518 .map(|cert| -> Result<_> {
519 let app_id = RocketCertificate(cert).get_app_id()?;
520 let app_info = RocketCertificate(cert).get_app_info()?;
521 Ok((app_id, app_info))
522 })
523 .transpose()?;
524 let (remote_app_id, remote_app_info) = match info {
525 Some((app_id, app_info)) => (app_id, app_info),
526 None => (None, None),
527 };
528 let attestation = request
529 .certificate
530 .as_ref()
531 .map(|cert| ra_tls::attestation::from_der(cert.as_bytes()))
532 .transpose()?
533 .flatten();
534 let attestation = match (request.quote_verifier, attestation) {
535 (Some(quote_verifier), Some(attestation)) => {
536 let pubkey = request
537 .certificate
538 .context("certificate is missing")?
539 .public_key()
540 .raw
541 .to_vec();
542 let verified = attestation
543 .into_v1()
544 .verify_with_ra_pubkey(&pubkey, quote_verifier.pccs_url.as_deref())
545 .await
546 .context("invalid quote")?;
547 Some(verified)
548 }
549 _ => None,
550 };
551 let payload = match data {
552 Some(data) => {
553 let limit = limit_for_method(method, request.limits);
554 read_data(data, limit)
555 .await
556 .context("failed to read data")?
557 }
558 None => request
559 .origin
560 .query()
561 .map_or(vec![], |q| q.as_bytes().to_vec()),

Callers

nothing calls this directly

Calls 11

RocketCertificateClass · 0.85
from_derFunction · 0.85
limit_for_methodFunction · 0.85
read_dataFunction · 0.85
get_app_idMethod · 0.80
get_app_infoMethod · 0.80
to_vecMethod · 0.80
verify_with_ra_pubkeyMethod · 0.80
into_v1Method · 0.80
as_refMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected