How do you parse the Subject Alternate Names from an X509Certificate2?

前端 未结 8 1985
孤街浪徒
孤街浪徒 2020-12-18 19:40

Is there an easy way to get the Subject Alternate Names from an X509Certificate2 object?

        foreach (X509Extension ext in certificate.Extensions)
               


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 20:38

    To get the "Subject Alternative Name" from a certificate:

    X509Certificate2 cert = /* your code here */;
    
    Console.WriteLine("UpnName : {0}{1}", cert.GetNameInfo(X509NameType.UpnName, false), Environment.NewLine);
    

提交回复
热议问题