使用Python从X509Store获取X509Certificate2

问题描述

我有以下使用.net c#的方法获取X509Certificate2的方法。 我需要在Python中复制它。

有人可以帮忙吗? 谢谢。

    public X509Certificate2 GetUserAuthenticationCertificate()
    {
        var store = new X509Store(StoreName.My = 5);
        store.Open(OpenFlags.ReadOnly);

        if (store.Certificates.Count > 0)
        {
            foreach (X509Certificate2 cert in store.Certificates)
            {
                foreach (X509Extension certExt in cert.Extensions)
                {
                    if (certExt.Oid.FriendlyName == "Enhanced Key Usage")
                    {
                        string strSubjectAltName = certExt.Format(false).ToLower();
                        if (strSubjectAltName.Contains("My Company logon".ToLower()))
                            return cert;
                    }
                }
            }
        }
        return null;
    }


  X509Certificate2 userCert = GetUserAuthenticationCertificate();

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)