Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificate fetch bug for Turin #83

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hyperv = ["tss-esapi"]
clap = { version = "4.5", features = [ "derive" ] }
env_logger = "0.10.0"
anyhow = "1.0.69"
sev = { version = "4.0", default-features = false, features = ['openssl','snp']}
sev = { version = "5.0.0", default-features = false, features = ['openssl','snp']}
nix = "^0.23"
serde = { version = "1.0", features = ["derive"] }
bincode = "^1.2.1"
Expand Down
11 changes: 5 additions & 6 deletions src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{fs, path::PathBuf, str::FromStr};

use reqwest::blocking::{get, Response};

use sev::firmware::host::CertType;
use sev::{certs::snp::ca::Chain, firmware::host::CertType};

use certs::{write_cert, CertFormat};

Expand Down Expand Up @@ -114,7 +114,6 @@ pub fn cmd(cmd: FetchCmd) -> Result<()> {

mod cert_authority {
use super::*;
use openssl::x509::X509;
use reqwest::StatusCode;

#[derive(Parser)]
Expand All @@ -140,7 +139,7 @@ mod cert_authority {
pub fn request_ca_kds(
processor_model: ProcType,
endorser: &Endorsement,
) -> Result<Vec<X509>, anyhow::Error> {
) -> Result<Chain, anyhow::Error> {
const KDS_CERT_SITE: &str = "https://kdsintf.amd.com";
const KDS_CERT_CHAIN: &str = "cert_chain";

Expand All @@ -161,7 +160,7 @@ mod cert_authority {
.context("Unable to parse AMD certificate chain")?
.to_vec();

let certificates = X509::stack_from_pem(&body)?;
let certificates = Chain::from_pem_bytes(&body)?;

Ok(certificates)
}
Expand All @@ -179,8 +178,8 @@ mod cert_authority {
fs::create_dir(&args.certs_dir).context("Could not create certs folder")?;
}

let ark_cert = &certificates[1];
let ask_cert = &certificates[0];
let ark_cert = certificates.ark;
let ask_cert = certificates.ask;

write_cert(
&args.certs_dir,
Expand Down
Loading