Monday, October 8, 2018

Get the Distinguished Name for an X509Certificate2 type certificate in C#.

If the X509Certificate2 object were named certificate...

string name = certificate.GetNameInfo(X509NameType.DnsName, false);

 
 

You need this name to renew a certificate via Venafi's API! Honestly, you may need a full-qualified distinguished name and I am still working on that. The Distinguished Name can be referred to as DNs (distinguished names) and here DNs is not to be confused with DNS which stands for Domain Name Services.

 
 

Addendum 10/10/2018: The fully qualified distinguished name is what is needed at Venafi and in the case of Venafi the code above is no good. Perhaps the code above is legitimate in other circumstances. I'm not sure. A fully qualified distinguished name at Venafi is going to look like a folder path with a series of things separated by double backslashes. \\VED\\Policy\\ is always how it starts and then there is probably another three chunks (the first of which denotes an account and middlemost being "Certificates") followed finally by the friendly name for the certificate at the end. There is no trailing slash even though there is a leading slash. It is alright to have spaces in the names.

No comments:

Post a Comment