We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent adfa71a commit 6676986Copy full SHA for 6676986
src/shared/Core/X509Utils.cs
@@ -0,0 +1,23 @@
1
+using System.Security.Cryptography.X509Certificates;
2
+
3
+namespace GitCredentialManager;
4
5
+public static class X509Utils
6
+{
7
+ public static X509Certificate2 GetCertificateByThumbprint(string thumbprint)
8
+ {
9
+ foreach (var location in new[]{StoreLocation.CurrentUser, StoreLocation.LocalMachine})
10
11
+ using var store = new X509Store(StoreName.My, location);
12
+ store.Open(OpenFlags.ReadOnly);
13
14
+ X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
15
+ if (certs.Count > 0)
16
17
+ return certs[0];
18
+ }
19
20
21
+ return null;
22
23
+}
0 commit comments