fix clippy warnings
This commit is contained in:
parent
683c49564d
commit
88d3207cb5
@ -390,14 +390,14 @@ impl Config {
|
||||
let private_key_path = Self::hratls_key_path()?;
|
||||
if Path::new(&private_key_path).exists() {
|
||||
log::debug!("Found HRaTLS private key at {private_key_path}");
|
||||
return Ok(std::fs::read_to_string(private_key_path)
|
||||
.map_err(|e| Error::CorruptedHratlsKey(e.to_string()))?);
|
||||
return std::fs::read_to_string(private_key_path)
|
||||
.map_err(|e| Error::CorruptedHratlsKey(e.to_string()));
|
||||
}
|
||||
let key = PKey::generate_ed25519()?;
|
||||
let mut key_file = File::create(private_key_path)?;
|
||||
let pem_pkcs8 = key.private_key_to_pem_pkcs8()?;
|
||||
key_file.write_all(&pem_pkcs8)?;
|
||||
Ok(String::from_utf8(pem_pkcs8).map_err(|e| Error::CorruptedHratlsKey(e.to_string()))?)
|
||||
String::from_utf8(pem_pkcs8).map_err(|e| Error::CorruptedHratlsKey(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn get_hratls_pubkey_hex() -> Result<String, Error> {
|
||||
@ -430,22 +430,22 @@ impl Config {
|
||||
|
||||
fn get_mrsigner_rsa_key() -> Result<Rsa<Private>, Error> {
|
||||
let signing_key_pem_str = Self::create_mrsigner_rsa_key()?;
|
||||
Ok(Rsa::private_key_from_pem(signing_key_pem_str.as_ref())
|
||||
.map_err(|e| Error::CorruptedMrSigner(e.to_string()))?)
|
||||
Rsa::private_key_from_pem(signing_key_pem_str.as_ref())
|
||||
.map_err(|e| Error::CorruptedMrSigner(e.to_string()))
|
||||
}
|
||||
|
||||
fn create_mrsigner_rsa_key() -> Result<String, Error> {
|
||||
let signing_key_path = Self::mrsigner_key_path()?;
|
||||
if Path::new(&signing_key_path).exists() {
|
||||
log::debug!("Found signing_key at {signing_key_path}");
|
||||
return Ok(std::fs::read_to_string(signing_key_path)
|
||||
.map_err(|e| Error::CorruptedMrSigner(e.to_string()))?);
|
||||
return std::fs::read_to_string(signing_key_path)
|
||||
.map_err(|e| Error::CorruptedMrSigner(e.to_string()));
|
||||
}
|
||||
let key = Rsa::generate_with_e(3072, BigNum::from_u32(3)?.as_ref())?;
|
||||
let mut key_file = File::create(signing_key_path)?;
|
||||
let pem_pkcs8 = key.private_key_to_pem()?;
|
||||
key_file.write_all(&pem_pkcs8)?;
|
||||
Ok(String::from_utf8(pem_pkcs8).map_err(|e| Error::CorruptedMrSigner(e.to_string()))?)
|
||||
String::from_utf8(pem_pkcs8).map_err(|e| Error::CorruptedMrSigner(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn mrsigner_key_path() -> Result<String, Error> {
|
||||
|
@ -63,14 +63,11 @@ impl Args {
|
||||
})?;
|
||||
if !script_result.status.success() {
|
||||
return Err(Error::FailedExecution(format!(
|
||||
"sev-snp-measure.py failed: {}",
|
||||
format!(
|
||||
"!!! stdout:\n{}\n!!! stderr:\n{}",
|
||||
String::from_utf8(script_result.stdout.clone())
|
||||
.unwrap_or("Could not grab stdout from installation script.".to_string()),
|
||||
String::from_utf8(script_result.stderr.clone())
|
||||
.unwrap_or("Could not grab stderr from installation script.".to_string())
|
||||
)
|
||||
"sev-snp-measure.py failed: !!! stdout:\n{}\n!!! stderr:\n{}",
|
||||
String::from_utf8(script_result.stdout.clone())
|
||||
.unwrap_or("Could not grab stdout from installation script.".to_string()),
|
||||
String::from_utf8(script_result.stderr.clone())
|
||||
.unwrap_or("Could not grab stderr from installation script.".to_string())
|
||||
)));
|
||||
}
|
||||
Ok(String::from_utf8(script_result.stdout)
|
||||
|
Loading…
Reference in New Issue
Block a user