(config: KmsConfig)
| 96 | |
| 97 | impl KmsState { |
| 98 | pub fn new(config: KmsConfig) -> Result<Self> { |
| 99 | let root_ca = CaCert::load(config.root_ca_cert(), config.root_ca_key()) |
| 100 | .context("Failed to load root CA certificate")?; |
| 101 | let key_bytes = fs::read(config.k256_key()).context("Failed to read ECDSA root key")?; |
| 102 | let k256_key = |
| 103 | SigningKey::from_slice(&key_bytes).context("Failed to load ECDSA root key")?; |
| 104 | let temp_ca_key = |
| 105 | fs::read_to_string(config.tmp_ca_key()).context("Faeild to read temp ca key")?; |
| 106 | let temp_ca_cert = |
| 107 | fs::read_to_string(config.tmp_ca_cert()).context("Faeild to read temp ca cert")?; |
| 108 | let verifier = CvmVerifier::new( |
| 109 | config.image.cache_dir.display().to_string(), |
| 110 | config.image.download_url.clone(), |
| 111 | config.image.download_timeout, |
| 112 | config.pccs_url.clone(), |
| 113 | ); |
| 114 | if !config.enforce_self_authorization { |
| 115 | warn!( |
| 116 | "self-authorization is disabled; trusted RPCs will not be gated by KMS self-attestation - do not use in production TEE deployments" |
| 117 | ); |
| 118 | } |
| 119 | Ok(Self { |
| 120 | inner: Arc::new(KmsStateInner { |
| 121 | config, |
| 122 | root_ca, |
| 123 | k256_key, |
| 124 | temp_ca_cert, |
| 125 | temp_ca_key, |
| 126 | verifier, |
| 127 | self_boot_info: OnceCell::new(), |
| 128 | metrics: KmsMetrics::default(), |
| 129 | }), |
| 130 | }) |
| 131 | } |
| 132 | |
| 133 | pub(crate) fn metrics(&self) -> &KmsMetrics { |
| 134 | &self.inner.metrics |
nothing calls this directly
no test coverage detected