Skip to content

Commit 10c6895

Browse files
mythifitzthum
authored andcommitted
ita: add USER_AGENT to HTTP header
USER_AGENT missing was noticed being missing in a review. Add an identity for "Coco trustee kbs" originated requests. Signed-off-by: Mikko Ylinen <[email protected]>
1 parent 7df333d commit 10c6895

File tree

1 file changed

+10
-1
lines changed
  • kbs/src/attestation/intel_trust_authority

1 file changed

+10
-1
lines changed

kbs/src/attestation/intel_trust_authority/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use az_cvm_vtpm::hcl::HclReport;
1414
use base64::{engine::general_purpose::STANDARD, Engine};
1515
use kbs_types::Challenge;
1616
use kbs_types::{Attestation, Tee};
17-
use reqwest::header::{ACCEPT, CONTENT_TYPE};
17+
use reqwest::header::{ACCEPT, CONTENT_TYPE, USER_AGENT};
1818
use serde::{Deserialize, Serialize};
1919
use serde_json::from_value;
2020
use serde_json::json;
@@ -29,6 +29,8 @@ const ERR_INVALID_TEE: &str = "ITA: Unknown TEE specified";
2929
const BASE_AS_ADDR: &str = "/appraisal/v1/attest";
3030
const AZURE_TDXVM_ADDR: &str = "/appraisal/v1/attest/azure/tdxvm";
3131

32+
const TRUSTEE_USER_AGENT: &str = "Confidential-containers-trustee";
33+
3234
#[derive(Display, EnumString, AsRefStr)]
3335
pub enum HashAlgorithm {
3436
#[strum(ascii_case_insensitive)]
@@ -147,9 +149,16 @@ impl Attest for IntelTrustAuthority {
147149
log::info!("POST attestation request ...");
148150
log::debug!("Attestation URL: {:?}", &att_url);
149151

152+
let user_agent = format!(
153+
"{TRUSTEE_USER_AGENT} {}/{}",
154+
env!("CARGO_PKG_NAME"),
155+
env!("CARGO_PKG_VERSION")
156+
);
157+
150158
let client = reqwest::Client::new();
151159
let resp = client
152160
.post(att_url)
161+
.header(USER_AGENT, user_agent)
153162
.header(CONTENT_TYPE, "application/json")
154163
.header(ACCEPT, "application/json")
155164
.header("x-api-key", &self.config.api_key)

0 commit comments

Comments
 (0)