Skip to content

Commit

Permalink
Fix certificate fetch bug for Turin
Browse files Browse the repository at this point in the history
Adding the new from_pem_bytes function to the fetch function for the CA
in order to solve the issue of different sized certificates for Turin.

Signed-off-by: DGonzalezVillal <[email protected]>
  • Loading branch information
DGonzalezVillal authored and tylerfanelli committed Dec 20, 2024
1 parent be35ce7 commit 0caf470
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
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

0 comments on commit 0caf470

Please sign in to comment.