internal static X509Certificate2 FindCert(string sHostname, bool allowCreate) { if (oCertProvider != null) { return(oCertProvider.GetCertificateForHost(sHostname)); } X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); string b = string.Format("CN={0}{1}", sHostname, CONFIG.sMakeCertSubjectO); X509Certificate2Enumerator enumerator = store.Certificates.GetEnumerator(); while (enumerator.MoveNext()) { X509Certificate2 current = enumerator.Current; if (string.Equals(current.Subject, b, StringComparison.OrdinalIgnoreCase)) { store.Close(); return(current); } } store.Close(); if (!allowCreate) { return(null); } bool flag = CreateCert(sHostname, false); X509Certificate2 certificate2 = FindCert(sHostname, false); if (certificate2 == null) { FiddlerApplication.Log.LogFormat("!Fiddler.CertMaker> Tried to create cert for {0}, got {1}, but can't find it from thread {2}!", new object[] { sHostname, flag.ToString(), Thread.CurrentThread.ManagedThreadId }); } return(certificate2); }
internal static X509Certificate2 FindCert(string sHostname, bool allowCreate) { return(oCertProvider.GetCertificateForHost(sHostname)); }