@@ -9,7 +9,8 @@ use dstack_guest_agent_rpc::{
99use dstack_kms_rpc:: {
1010 kms_client:: KmsClient ,
1111 onboard_server:: { OnboardRpc , OnboardServer } ,
12- BootstrapRequest , BootstrapResponse , GetKmsKeyRequest , OnboardRequest , OnboardResponse ,
12+ AttestationInfoResponse , BootstrapRequest , BootstrapResponse , GetKmsKeyRequest , OnboardRequest ,
13+ OnboardResponse ,
1314} ;
1415use fs_err as fs;
1516use http_client:: prpc:: PrpcClient ;
@@ -90,6 +91,47 @@ impl OnboardRpc for OnboardHandler {
9091 Ok ( OnboardResponse { } )
9192 }
9293
94+ async fn get_attestation_info ( self ) -> Result < AttestationInfoResponse > {
95+ let pccs_url = self . state . config . pccs_url . clone ( ) ;
96+
97+ // Get attestation from guest agent
98+ let report_data = pad64 ( [ 0u8 ; 32 ] ) ;
99+ let response = app_attest ( report_data)
100+ . await
101+ . context ( "Failed to get attestation" ) ?;
102+
103+ // Decode and verify the attestation to get real device ID
104+ let attestation = VersionedAttestation :: from_scale ( & response. attestation )
105+ . context ( "Failed to decode attestation" ) ?
106+ . into_inner ( ) ;
107+ let attestation_mode = serde_json:: to_value ( attestation. quote . mode ( ) )
108+ . ok ( )
109+ . and_then ( |v| v. as_str ( ) . map ( String :: from) )
110+ . unwrap_or_else ( || format ! ( "{:?}" , attestation. quote. mode( ) ) ) ;
111+ let verified = attestation
112+ . verify ( pccs_url. as_deref ( ) )
113+ . await
114+ . context ( "Failed to verify attestation" ) ?;
115+
116+ // Get vm_config from guest agent
117+ let info = dstack_client ( )
118+ . info ( )
119+ . await
120+ . context ( "Failed to get VM info" ) ?;
121+
122+ // Decode app info to get device_id, mr_aggregated, os_image_hash, mr_system
123+ let app_info = verified
124+ . decode_app_info_ex ( false , & info. vm_config )
125+ . context ( "Failed to decode app info" ) ?;
126+
127+ Ok ( AttestationInfoResponse {
128+ device_id : app_info. device_id ,
129+ mr_aggregated : app_info. mr_aggregated . to_vec ( ) ,
130+ os_image_hash : app_info. os_image_hash ,
131+ attestation_mode,
132+ } )
133+ }
134+
93135 async fn finish ( self ) -> anyhow:: Result < ( ) > {
94136 std:: process:: exit ( 0 ) ;
95137 }
0 commit comments