[#787] Saving attestation certificate to file (#788)

* Saving attestation certificate to file

* Updates to provisioner certificate generation
This commit is contained in:
CAFB385655BEB1060E85B6C080B432F8EB2A2AF78459BD6532124977B933154A 2024-06-21 10:13:18 -04:00 committed by GitHub
parent 7037429f06
commit ca0646d946
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,9 @@ namespace hirs {
private Settings settings = null;
private IHirsDeviceInfoCollector deviceInfoCollector = null;
private IHirsAcaClient acaClient = null;
private const string DefaultCertFileName = "attestationkey.pem";
public Provisioner() {
}
@ -279,6 +282,20 @@ namespace hirs {
}
if (cr.HasCertificate) {
certificate = cr.Certificate.ToByteArray(); // contains certificate
String certificateDirPath = settings.efi_prefix;
if (certificateDirPath != null) {
String certificateFilePath = certificateFilePath = certificateDirPath + DefaultCertFileName;
try {
if (!Directory.Exists(certificateDirPath)) {
Directory.CreateDirectory(certificateDirPath);
}
File.WriteAllBytes(certificateFilePath, certificate);
Log.Debug("Certificate written to local file system: ", certificateFilePath);
}
catch (Exception) {
Log.Debug("Failed to write certificate to local file system.");
}
}
Log.Debug("Printing attestation key certificate: " + BitConverter.ToString(certificate));
}
} else {