Skip to main content

CollateralClient

Struct CollateralClient 

Source
pub struct CollateralClient<C: Config = DefaultConfig, H: HttpClient = ReqwestHttp> { /* private fields */ }
Expand description

A PCCS / PCS client parameterized by Config for pluggable X.509 / crypto backends, and by HttpClient for the HTTP transport.

H defaults to a crate-private reqwest-backed adapter (gated on feature = "reqwest"). reqwest::Client deliberately does not appear in any public function signature, so a future reqwest major bump is an internal change rather than a breaking one for downstream callers. To plug in a custom HTTP stack — different TLS config, workspace-pinned reqwest major, non-reqwest transport, wasm host fetch, … — implement HttpClient on your own type and hand it to new.

Exposes three fetch methods:

§Examples

Default path — let the crate build a reqwest-backed transport:

use dcap_qvl::collateral::{CollateralClient, PHALA_PCCS_URL};
let collateral = CollateralClient::with_default_http(PHALA_PCCS_URL)?
    .fetch(&quote)
    .await?;

Custom transport — implement HttpClient on a type you own:

use dcap_qvl::collateral::CollateralClient;
use dcap_qvl::http::{HttpClient, HttpResponse};

struct MyHttp { /* your HTTP client of choice */ }

impl HttpClient for MyHttp {
    async fn get(&self, url: &str) -> anyhow::Result<HttpResponse> {
        /* … */
    }
}

let client = CollateralClient::<_, MyHttp>::new(MyHttp { /* … */ }, "https://pccs.local");

Implementations§

Source§

impl<C: Config, H: HttpClient> CollateralClient<C, H>

Source

pub fn new(http: H, pccs_url: impl Into<String>) -> Self

Build a client with a caller-provided HTTP transport.

Any type implementing HttpClient is accepted. For the common “just give me something that works” path see with_default_http; the default-path reqwest::Client is intentionally not exposed on the public API.

Source

pub fn with_config<D: Config>(self) -> CollateralClient<D, H>

Rebind the Config type without rebuilding the HTTP client / URL.

Source

pub fn with_evaluation_data_set( self, evaluation_data_set: TcbEvaluationDataSet, ) -> Self

Choose which TCB evaluation data set the PCS serves, defaulting to TcbEvaluationDataSet::Standard.

Early answers whether a platform will still be accepted once Intel promotes the set it has already published.

Source

pub async fn fetch(&self, quote: &[u8]) -> Result<QuoteCollateralV3>

Fetch collateral for the given raw DCAP quote.

Decodes the quote, fetches (or extracts) the PCK certificate chain, reads FMSPC + CA type from the leaf cert via the configured X509Codec, and then fetches the remaining collateral items. The returned QuoteCollateralV3 has the PCK chain attached in pck_certificate_chain for offline verification.

Source

pub async fn fetch_for_fmspc_without_pck_chain( &self, fmspc: &str, ca: &str, for_sgx: bool, ) -> Result<QuoteCollateralV3>

Fetch the per-fmspc collateral bundle (PCK CRL, TCB info, QE identity, root CA CRL) when FMSPC and CA type are already known.

NOTE:

  • Deliberately returns a QuoteCollateralV3 with pck_certificate_chain = None, so the output on its own is insufficient to verify a quote whose certification data doesn’t embed the PCK chain.
  • Use fetch for verification purposes.
Source

pub async fn fetch_and_verify(&self, quote: &[u8]) -> Result<VerifiedReport>

Fetch collateral and run verification in one step, using the configured Config’s crypto and x509 backends.

Source§

impl CollateralClient<DefaultConfig, ReqwestHttp>

Source

pub fn with_default_http(pccs_url: impl Into<String>) -> Result<Self>

Convenience constructor: build a default reqwest-backed transport (180s timeout on non-js targets) and pair it with the given PCCS URL. Uses DefaultConfig (audited x509-cert backend). The underlying reqwest::Client is intentionally not exposed; callers who need a custom HTTP stack implement HttpClient on their own type and use CollateralClient::new.

Source

pub fn from_env() -> Result<Self>

Zero-arg convenience constructor: default HTTP client + PCCS URL from the PCCS_URL env var (trimmed; empty is treated as unset), falling back to PHALA_PCCS_URL. Uses DefaultConfig.

Trait Implementations§

Source§

impl<C: Config, H: HttpClient + Clone> Clone for CollateralClient<C, H>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<C, H> Freeze for CollateralClient<C, H>
where H: Freeze, PhantomData<fn() -> C>: Freeze,

§

impl<C, H> RefUnwindSafe for CollateralClient<C, H>

§

impl<C, H> Send for CollateralClient<C, H>
where H: Send, PhantomData<fn() -> C>: Send,

§

impl<C, H> Sync for CollateralClient<C, H>
where H: Sync, PhantomData<fn() -> C>: Sync,

§

impl<C, H> Unpin for CollateralClient<C, H>
where H: Unpin, PhantomData<fn() -> C>: Unpin,

§

impl<C, H> UnsafeUnpin for CollateralClient<C, H>

§

impl<C, H> UnwindSafe for CollateralClient<C, H>
where H: UnwindSafe, PhantomData<fn() -> C>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more