Extract certificates from provisioned devices
Extract certificates via API
C# example
public static void GetKeyAndCerts()
{
medcrypt.guardian.InitializeFiles initializeFiles =
new medcrypt.guardian.InitializeFiles();
/* read provisioned files into file structure */
initializeFiles.trustStore =
File.ReadAllBytes(@"TrustStore.mcts");
initializeFiles.privateIdentity =
File.ReadAllBytes(@"PrivateIdentity.mcpi");
initializeFiles.certifiedProfile =
File.ReadAllBytes(@"CertifiedProfile.mcp");
/* customer data about the provisioning system */
string componentHandle = "my_component_handle";
string hardwareId = "my_serial_number";
string serviceName = "my_service_name";
/* accept input options, or create default */
medcrypt.guardian.InitializeOptions options =
new medcrypt.guardian.InitializeOptions();
/* initialize guardian for configured operations (key and cert)*/
medcrypt.guardian.Guardian gdn = new medcrypt.guardian.Guardian();
gdn.Initialize(
initializeFiles,
componentHandle,
hardwareId,
new medcrypt.guardian.InitializeOptions());
List<byte[]> certs = null;
byte[] key = null;
medcrypt.guardian.IService service = gdn.FindService(serviceName);
/* get key */
key = service.GetCertificateKey(KeyFormat.PKCS8_PEM);
/* get length of certificate chain, and add all certs to output
list */
ulong chainLen = service.GetCertificateChainLength();
certs = new List<byte[]>();
for (ulong i = 0; i < chainLen; i++)
{
certs.Add(service.GetCertificate(i, CertFormat.PEM));
}
}C++ example
C example
Extract certificates via command line
Last updated