Both Subject and SubjectName properties of X509Certificate2 have the full distinguished name (ex: “CN = Rags, OU = UserAccounts, DC = corp, O = microsoft”). But what if we only want the common name part of it (in this case “Rags”). This was unintuitive to find, but I finally figured out. You use
cert.GetNameInfo(X509NameType.SimpleName, false)
This prevents parsing the string etc and is certainly better!
4 comments:
THANK YOU
Thank you..!! for the Post, it saves my time. :)
Thank you!!!
thanks for sharing
Post a Comment