mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-26 09:04:47 +02:00
refactor(intel-dcap-api): split client.rs into smaller files
Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
parent
ed84a424db
commit
0e69105a43
9 changed files with 1410 additions and 1324 deletions
67
crates/intel-dcap-api/src/client/pck_crl.rs
Normal file
67
crates/intel-dcap-api/src/client/pck_crl.rs
Normal file
|
@ -0,0 +1,67 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (c) 2025 Matter Labs
|
||||
|
||||
use super::ApiClient; // Import from parent module
|
||||
use crate::{
|
||||
error::{check_status, IntelApiError},
|
||||
responses::PckCrlResponse,
|
||||
types::{CaType, CrlEncoding},
|
||||
};
|
||||
use reqwest::StatusCode;
|
||||
|
||||
impl ApiClient {
|
||||
/// GET /sgx/certification/{v3,v4}/pckcrl
|
||||
/// Retrieves the PCK Certificate Revocation List (CRL) for a specified CA type.
|
||||
///
|
||||
/// Optionally takes an `encoding` parameter indicating whether the CRL should be
|
||||
/// returned as PEM or DER. Defaults to PEM if not specified.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ca_type` - The type of CA to retrieve the CRL for (e.g., "processor" or "platform").
|
||||
/// * `encoding` - An optional [`CrlEncoding`] (PEM or DER).
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A [`PckCrlResponse`] containing the CRL data and the issuer chain.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an `IntelApiError` if the request fails or if the response status
|
||||
/// is not `200 OK`.
|
||||
/// Optional 'encoding' parameter ("pem" or "der").
|
||||
/// Returns CRL data (PEM or DER) and Issuer Chain header.
|
||||
pub async fn get_pck_crl(
|
||||
&self,
|
||||
ca_type: CaType,
|
||||
encoding: Option<CrlEncoding>,
|
||||
) -> Result<PckCrlResponse, IntelApiError> {
|
||||
let path = self.build_api_path("sgx", "", "pckcrl")?;
|
||||
let mut url = self.base_url.join(&path)?;
|
||||
url.query_pairs_mut()
|
||||
.append_pair("ca", &ca_type.to_string());
|
||||
|
||||
if let Some(enc) = encoding {
|
||||
url.query_pairs_mut()
|
||||
.append_pair("encoding", &enc.to_string());
|
||||
}
|
||||
|
||||
let request_builder = self.client.get(url);
|
||||
let response = request_builder.send().await?;
|
||||
let response = check_status(response, &[StatusCode::OK]).await?;
|
||||
|
||||
let issuer_chain = self.get_required_header(
|
||||
&response,
|
||||
"SGX-PCK-CRL-Issuer-Chain", // v4 name
|
||||
Some("SGX-PCK-CRL-Issuer-Chain"), // v3 name
|
||||
)?;
|
||||
|
||||
// Response body is PEM or DER CRL
|
||||
let crl_data = response.bytes().await?.to_vec();
|
||||
|
||||
Ok(PckCrlResponse {
|
||||
crl_data,
|
||||
issuer_chain,
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue