0
votes

This may seem like a very basic question, but I've created a KeyVault in Azure and have added a pfx file containing a certificate/publickey to it .

Now using C# code I'm trying to access the public key and from that I want get the expiry-date attribute details. I can see that the certificate expiry date from the certificate manager utility in windows, however I can't seem to work out any way to actually retrieve the same thing in my c# code.

//Below is the code i'm using KeyVaultClient client = new KeyVaultClient(GetAccessToken); var keyBundle = client.GetKeyAsync(vaultUri, wrappingKeyName).Result; // After this KeyBundle.Key doesn't have the necessary details

Can anyone provide the missing link, as the current documentation on the Microsoft site isn't too expansive at present.

1

1 Answers

0
votes

You should be able to get the Expiry from the key bundle as below

var keyIdentifier = "https://rahulkeyvault.vault.azure.net:443/keys/NewKey";
var key = await keyClient.GetKeyAsync(keyIdentifier);
var keyExpiry = key.Attributes.Expires;

This depends on if you have mentioned an expiry at the time of creating the key by setting the -Expires flag