Skip to content

Commit 8aa17ec

Browse files
committed
verifier-cli: Add command to get PlatformId from attestation cert chain
1 parent fd20945 commit 8aa17ec

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

verifier-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MPL-2.0"
99
anyhow = { workspace = true, features = ["std"] }
1010
attest-data = { path = "../attest-data", features = ["std"] }
1111
clap.workspace = true
12-
const-oid = { workspace = true, features = ["db"] }
12+
dice-mfg-msgs = { path = "../dice-mfg-msgs", features = ["std"] }
1313
ed25519-dalek = { workspace = true, features = ["std"] }
1414
env_logger.workspace = true
1515
hubpack.workspace = true

verifier-cli/src/main.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use anyhow::{anyhow, Context, Result};
66
use attest_data::{Attestation, Log, Nonce};
77
use clap::{Parser, Subcommand, ValueEnum};
8+
use dice_mfg_msgs::PlatformId;
89
use dice_verifier::PkiPathSignatureVerifier;
910
use env_logger::Builder;
1011
use hubpack::SerializedSize;
@@ -76,6 +77,12 @@ enum AttestCommand {
7677
Log,
7778
/// Get the length in bytes of the Log.
7879
LogLen,
80+
/// Get the PlatformId string from the provided PkiPath
81+
PlatformId {
82+
/// Path to file holding the certificate chain / PkiPath
83+
#[clap(env)]
84+
cert_chain: PathBuf,
85+
},
7986
/// Report a measurement to the `Attest` task for recording in the
8087
/// measurement log.
8188
Record {
@@ -498,7 +505,6 @@ fn main() -> Result<()> {
498505
AttestCommand::CertChainLen => println!("{}", attest.cert_chain_len()?),
499506
AttestCommand::CertLen { index } => {
500507
println!("{}", attest.cert_len(index)?)
501-
}
502508
AttestCommand::Log => {
503509
let mut log = vec![0u8; attest.log_len()? as usize];
504510
attest.log(&mut log)?;
@@ -512,6 +518,18 @@ fn main() -> Result<()> {
512518
io::stdout().flush()?;
513519
}
514520
AttestCommand::LogLen => println!("{}", attest.log_len()?),
521+
AttestCommand::PlatformId { cert_chain } => {
522+
let cert_chain = fs::read(cert_chain)?;
523+
let cert_chain: PkiPath = Certificate::load_pem_chain(&cert_chain)?;
524+
525+
let platform_id = PlatformId::try_from(&cert_chain)
526+
.context("PlatformId from attestation cert chain")?;
527+
let platform_id = platform_id
528+
.as_str()
529+
.map_err(|_| anyhow!("Invalid PlatformId"))?;
530+
531+
println!("{platform_id}");
532+
}
515533
AttestCommand::Record { digest } => {
516534
let digest = fs::read(digest)?;
517535
attest.record(&digest)?;

0 commit comments

Comments
 (0)