Advtools.AdvInterceptor.CertificatesManager.LoadCertificate C# (CSharp) Method

LoadCertificate() private method

private LoadCertificate ( string name, System.Security.Cryptography.X509Certificates storeName, System.Security.Cryptography.X509Certificates location ) : X509Certificate2
name string
storeName System.Security.Cryptography.X509Certificates
location System.Security.Cryptography.X509Certificates
return System.Security.Cryptography.X509Certificates.X509Certificate2
        private MSX509.X509Certificate2 LoadCertificate(string name, MSX509.StoreName storeName, MSX509.StoreLocation location)
        {
            if(certificates_.ContainsKey(name))
                return certificates_[name];

            MSX509.X509Store store = new MSX509.X509Store(storeName, location);
            store.Open(MSX509.OpenFlags.ReadOnly);
            var certificates = store.Certificates.Find(MSX509.X509FindType.FindBySubjectName, name, true);
            store.Close();

            if(certificates.Count <= 0)
                return null;

            state_.Logger.Information("X509v3 '{0}' loaded from store", name);

            MSX509.X509Certificate2 certificate = certificates[0];
            certificates_[name] = certificate;
            return certificate;
        }