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:
fetch— from a raw DCAP quote.fetch_for_fmspc— when the caller already has the FMSPC / CA type (skips PCK chain extraction).fetch_and_verify— fetch collateral and runQuoteVerifier::verifyin one shot (feature-gated on_anycrypto).
§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("e)
.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>
impl<C: Config, H: HttpClient> CollateralClient<C, H>
Sourcepub fn new(http: H, pccs_url: impl Into<String>) -> Self
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.
Sourcepub fn with_config<D: Config>(self) -> CollateralClient<D, H>
pub fn with_config<D: Config>(self) -> CollateralClient<D, H>
Rebind the Config type without rebuilding the HTTP client / URL.
Sourcepub fn with_evaluation_data_set(
self,
evaluation_data_set: TcbEvaluationDataSet,
) -> Self
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.
Sourcepub async fn fetch(&self, quote: &[u8]) -> Result<QuoteCollateralV3>
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.
Sourcepub async fn fetch_for_fmspc_without_pck_chain(
&self,
fmspc: &str,
ca: &str,
for_sgx: bool,
) -> Result<QuoteCollateralV3>
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
QuoteCollateralV3withpck_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
fetchfor verification purposes.
Sourcepub async fn fetch_and_verify(&self, quote: &[u8]) -> Result<VerifiedReport>
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>
impl CollateralClient<DefaultConfig, ReqwestHttp>
Sourcepub fn with_default_http(pccs_url: impl Into<String>) -> Result<Self>
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.
Sourcepub fn from_env() -> Result<Self>
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§
Auto Trait Implementations§
impl<C, H> Freeze for CollateralClient<C, H>
impl<C, H> RefUnwindSafe for CollateralClient<C, H>
impl<C, H> Send for CollateralClient<C, H>
impl<C, H> Sync for CollateralClient<C, H>
impl<C, H> Unpin for CollateralClient<C, H>
impl<C, H> UnsafeUnpin for CollateralClient<C, H>
impl<C, H> UnwindSafe for CollateralClient<C, H>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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