Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8447acf

Browse files
authored
Add CU\My to the search path for resolving cert chains on Linux
1 parent 1885cf8 commit 8447acf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509ChainProcessor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,19 @@ internal static HashSet<X509Certificate2> FindCandidates(
380380
using (var systemIntermediateStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine))
381381
using (var userRootStore = new X509Store(StoreName.Root, StoreLocation.CurrentUser))
382382
using (var userIntermediateStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.CurrentUser))
383+
using (var userMyStore = new X509Store(StoreName.My, StoreLocation.CurrentUser))
383384
{
384385
systemRootStore.Open(OpenFlags.ReadOnly);
385386
systemIntermediateStore.Open(OpenFlags.ReadOnly);
386387
userRootStore.Open(OpenFlags.ReadOnly);
387388
userIntermediateStore.Open(OpenFlags.ReadOnly);
389+
userMyStore.Open(OpenFlags.ReadOnly);
388390

389391
X509Certificate2Collection systemRootCerts = systemRootStore.Certificates;
390392
X509Certificate2Collection systemIntermediateCerts = systemIntermediateStore.Certificates;
391393
X509Certificate2Collection userRootCerts = userRootStore.Certificates;
392394
X509Certificate2Collection userIntermediateCerts = userIntermediateStore.Certificates;
395+
X509Certificate2Collection userMyCerts = userMyStore.Certificates;
393396

394397
// fill the system trusted collection
395398
foreach (X509Certificate2 userRootCert in userRootCerts)
@@ -416,6 +419,7 @@ internal static HashSet<X509Certificate2> FindCandidates(
416419
X509Certificate2Collection[] storesToCheck =
417420
{
418421
extraStore,
422+
userMyCerts,
419423
userIntermediateCerts,
420424
systemIntermediateCerts,
421425
userRootCerts,
@@ -452,7 +456,7 @@ internal static HashSet<X509Certificate2> FindCandidates(
452456
candidates,
453457
ReferenceEqualityComparer<X509Certificate2>.Instance);
454458

455-
// Certificates come from 5 sources:
459+
// Certificates come from 6 sources:
456460
// 1) extraStore.
457461
// These are cert objects that are provided by the user, we shouldn't dispose them.
458462
// 2) the machine root store
@@ -463,8 +467,11 @@ internal static HashSet<X509Certificate2> FindCandidates(
463467
// These certs were either path candidates, or not. If they were, don't dispose them. Otherwise do.
464468
// 5) the user intermediate store
465469
// These certs were either path candidates, or not. If they were, don't dispose them. Otherwise do.
470+
// 6) the user my store
471+
// These certs were either path candidates, or not. If they were, don't dispose them. Otherwise do.
466472
DisposeUnreferenced(candidatesByReference, systemIntermediateCerts);
467473
DisposeUnreferenced(candidatesByReference, userIntermediateCerts);
474+
DisposeUnreferenced(candidatesByReference, userMyCerts);
468475
}
469476

470477
return candidates;

0 commit comments

Comments
 (0)