Skip to content

Commit c6d1d1b

Browse files
committed
ra-tls: Support for app info in RATLS cert
1 parent 71f1ec4 commit c6d1d1b

16 files changed

Lines changed: 122 additions & 18 deletions

File tree

Cargo.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ size-parser = { path = "size-parser" }
8989

9090
# Core dependencies
9191
anyhow = { version = "1.0.97", default-features = false }
92+
errify = { version = "0.3.0", features = ["anyhow"] }
9293
or-panic = { version = "1.0", default-features = false }
9394
chrono = "0.4.40"
9495
clap = { version = "4.5.32", features = ["derive", "string"] }
@@ -124,6 +125,7 @@ serde = { version = "1.0.228", features = ["derive"], default-features = false }
124125
serde-human-bytes = "0.1.2"
125126
serde_json = { version = "1.0.140", default-features = false }
126127
serde_ini = "0.2.0"
128+
rmp-serde = "1.3.1"
127129
toml = "0.8.20"
128130
toml_edit = { version = "0.22.24", features = ["serde"] }
129131
yasna = "0.5.2"

dstack-attest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ sha2.workspace = true
2727
sha3.workspace = true
2828
tdx-attest.workspace = true
2929
insta.workspace = true
30+
errify.workspace = true
3031

3132
[features]
3233
quote = []

dstack-attest/src/attestation.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ impl VersionedAttestation {
260260
}
261261
}
262262

263+
/// Get app info
264+
pub fn decode_app_info(&self, boottime_mr: bool) -> Result<AppInfo> {
265+
match self {
266+
Self::V0 { attestation } => attestation.decode_app_info(boottime_mr),
267+
}
268+
}
269+
263270
/// Strip data for certificate embedding (e.g. keep RTMR3 event logs only).
264271
pub fn into_stripped(mut self) -> Self {
265272
let VersionedAttestation::V0 { attestation } = &mut self;
@@ -444,6 +451,7 @@ impl<T: GetDeviceId> Attestation<T> {
444451
self.decode_app_info_ex(boottime_mr, "")
445452
}
446453

454+
#[errify::errify("decode app info")]
447455
pub fn decode_app_info_ex(&self, boottime_mr: bool, vm_config: &str) -> Result<AppInfo> {
448456
let key_provider_info = if boottime_mr {
449457
vec![]
@@ -739,7 +747,7 @@ pub fn validate_tcb(report: &TdxVerifiedReport) -> Result<()> {
739747
}
740748

741749
/// Information about the app extracted from event log
742-
#[derive(Debug, Clone, Serialize)]
750+
#[derive(Debug, Clone, Serialize, Deserialize)]
743751
pub struct AppInfo {
744752
/// App ID
745753
#[serde(with = "hex_bytes")]

dstack-util/src/system_setup.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ impl<'a> GatewayContext<'a> {
391391
subject_alt_names: vec![],
392392
usage_server_auth: false,
393393
usage_client_auth: true,
394-
ext_quote: true,
394+
ext_quote: false,
395+
ext_app_info: true,
395396
not_before: None,
396397
not_after: None,
397398
};

gateway/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async fn maybe_gen_certs(config: &Config, tls_config: &TlsConfig) -> Result<()>
7777
usage_ra_tls: true,
7878
usage_server_auth: true,
7979
usage_client_auth: false,
80+
with_app_info: false,
8081
not_before: None,
8182
not_after: None,
8283
})

gateway/src/main_service/sync_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub(crate) async fn sync_task(proxy: Proxy) -> Result<()> {
9090
usage_ra_tls: false,
9191
usage_server_auth: false,
9292
usage_client_auth: true,
93+
with_app_info: false,
9394
not_after: None,
9495
not_before: None,
9596
})

guest-agent/rpc/proto/agent_rpc.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ message GetTlsKeyArgs {
7676
optional uint64 not_before = 6;
7777
// Certificate validity end time as seconds since UNIX epoch
7878
optional uint64 not_after = 7;
79+
// Includes app info in the certificate
80+
bool with_app_info = 8;
7981
}
8082

8183
// The request to derive a key

guest-agent/src/rpc_service.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ impl AppStateInner {
8585
usage_server_auth: false,
8686
usage_client_auth: true,
8787
ext_quote: true,
88+
ext_app_info: false,
8889
not_after: None,
8990
not_before: None,
9091
},
@@ -242,6 +243,7 @@ impl DstackGuestRpc for InternalRpcHandler {
242243
usage_server_auth: request.usage_server_auth,
243244
usage_client_auth: request.usage_client_auth,
244245
ext_quote: request.usage_ra_tls,
246+
ext_app_info: request.with_app_info,
245247
not_after: request.not_after,
246248
not_before: request.not_before,
247249
};
@@ -504,6 +506,7 @@ impl TappdRpc for InternalRpcHandlerV0 {
504506
usage_server_auth: request.usage_server_auth,
505507
usage_client_auth: request.usage_client_auth,
506508
ext_quote: request.usage_ra_tls,
509+
ext_app_info: false,
507510
not_before: None,
508511
not_after: None,
509512
};

ra-rpc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{fmt::Display, net::SocketAddr, path::PathBuf};
88

99
use anyhow::Result;
1010
use prpc::{codec::encode_message_to_vec, server::Service as PrpcService};
11+
use ra_tls::attestation::AppInfo;
1112
use tracing::{error, info};
1213

1314
pub use ra_tls::attestation::{Attestation, VerifiedAttestation};
@@ -36,6 +37,7 @@ pub struct CallContext<'a, State> {
3637
pub attestation: Option<VerifiedAttestation>,
3738
pub remote_endpoint: Option<RemoteEndpoint>,
3839
pub remote_app_id: Option<Vec<u8>>,
40+
pub remote_app_info: Option<AppInfo>,
3941
}
4042

4143
pub trait RpcCall<State>: Sized {

0 commit comments

Comments
 (0)