use crate::tdx::ExpectedBootchain;
#[derive(Debug, Clone)]
pub struct DstackTDXVerifierConfig {
pub app_compose: Option<serde_json::Value>,
pub allowed_tcb_status: Vec<String>,
pub disable_runtime_verification: bool,
pub expected_bootchain: Option<ExpectedBootchain>,
pub os_image_hash: Option<String>,
pub pccs_url: Option<String>,
pub cache_collateral: bool,
}
impl Default for DstackTDXVerifierConfig {
fn default() -> Self {
Self {
app_compose: None,
allowed_tcb_status: vec!["UpToDate".to_string()],
disable_runtime_verification: false,
expected_bootchain: None,
os_image_hash: None,
pccs_url: None,
cache_collateral: true,
}
}
}
pub struct DstackTDXVerifierBuilder {
config: DstackTDXVerifierConfig,
}
impl Default for DstackTDXVerifierBuilder {
fn default() -> Self {
Self::new()
}
}
impl DstackTDXVerifierBuilder {
pub fn new() -> Self {
Self {
config: DstackTDXVerifierConfig::default(),
}
}
pub fn app_compose(mut self, value: serde_json::Value) -> Self {
self.config.app_compose = Some(value);
self
}
pub fn expected_bootchain(mut self, bootchain: ExpectedBootchain) -> Self {
self.config.expected_bootchain = Some(bootchain);
self
}
pub fn os_image_hash(mut self, hash: impl Into<String>) -> Self {
self.config.os_image_hash = Some(hash.into());
self
}
pub fn allowed_tcb_status(mut self, statuses: Vec<String>) -> Self {
self.config.allowed_tcb_status = statuses;
self
}
pub fn pccs_url(mut self, url: impl Into<String>) -> Self {
self.config.pccs_url = Some(url.into());
self
}
pub fn disable_runtime_verification(mut self) -> Self {
self.config.disable_runtime_verification = true;
self
}
pub fn cache_collateral(mut self, enabled: bool) -> Self {
self.config.cache_collateral = enabled;
self
}
pub fn into_config(self) -> DstackTDXVerifierConfig {
self.config
}
pub fn build(self) -> Result<super::DstackTDXVerifier, crate::AtlsVerificationError> {
super::DstackTDXVerifier::new(self.config)
}
}