You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.Where(x =>x.HasPrivateKey&&Regex.IsMatch(x.Subject,string.Format("(^|,\\s?)CN={0}(,|$)",this.CertificatePathOrSubjectCommonName)))// We only want certificates, that have private keys, as we need them. We also want a complete CN match
122
+
.OrderByDescending(x =>x.Verify())// Ordering by validity in a descending order will bring valid certificates to the beginning
123
+
.ThenBy(x =>x.NotBefore)// We take the one, that was issued earliest, first
124
+
.ThenByDescending(x =>x.NotAfter)// We then take the one, that is valid for the longest period
125
+
.ToArray();
126
+
127
+
LogCertificateCounts(tracer,metadata,certsWithMatchingCns,"Found {0} certificates with a private key and an exact CN match. DNs (sorted by priority, will take first): {1}");
128
+
129
+
returncertsWithMatchingCns.FirstOrDefault();
98
130
}
99
131
}
100
132
catch(CryptographicExceptioncryptEx)
@@ -104,16 +136,43 @@ public X509Certificate2 GetCertificate(ITracer tracer, string certificatePasswor
104
136
returnnull;
105
137
}
106
138
107
-
tracer.RelatedError("Certificate {0} not found",this.CertificatePathOrSubjectCommonName);
0 commit comments