Skip to content

Instantly share code, notes, and snippets.

@buchizo
Created June 8, 2025 16:49
Show Gist options
  • Save buchizo/37f88fd127fc8eec5aad038f0bf35643 to your computer and use it in GitHub Desktop.
Save buchizo/37f88fd127fc8eec5aad038f0bf35643 to your computer and use it in GitHub Desktop.
get pfx from Azure KeyVault
var secretClient = new SecretClient(new Uri("https://___.vault.azure.net"), new DefaultAzureCredential());
var certClient = new CertificateClient(new Uri("https://___.vault.azure.net"), new DefaultAzureCredential());
var cert = await certClient.GetCertificateAsync("localhostcert");
var secret = await secretClient.GetSecretAsync(cert.Value.Name);
var pfxb = Convert.FromBase64String(secret.Value.Value);
var x509cert = X509CertificateLoader.LoadPkcs12(pfxb, "", X509KeyStorageFlags.MachineKeySet);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment