Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b32a91

Browse files
committedSep 26, 2023
Small refactor to BuildElement to address NRT changes
1 parent 6119823 commit 0b32a91

File tree

1 file changed

+7
-9
lines changed
  • src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates

1 file changed

+7
-9
lines changed
 

‎src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ChainPal.Apple.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,14 @@ private void BuildAndSetProperties((X509Certificate2, int)[] elementTuples)
348348

349349
for (int i = 0; i < elementTuples.Length; i++)
350350
{
351-
(X509Certificate2, int) tuple = elementTuples[i];
351+
(X509Certificate2 cert, int chainStatus) = elementTuples[i];
352352

353-
elements[i] = BuildElement(tuple.Item1, tuple.Item2);
354-
allStatus |= tuple.Item2;
353+
elements[i] = new X509ChainElement(cert, BuildChainElementStatuses(cert, chainStatus), "");
354+
allStatus |= chainStatus;
355355
}
356356

357357
ChainElements = elements;
358-
359-
X509ChainElement rollupElement = BuildElement(null!, allStatus);
360-
ChainStatus = rollupElement.ChainElementStatus;
358+
ChainStatus = BuildChainElementStatuses(null, allStatus);
361359
}
362360

363361
private static void FixupRevocationStatus(
@@ -457,11 +455,11 @@ private static X509ChainStatusFlags FindUntrustedRootReason(X509Certificate2 cer
457455
return X509ChainStatusFlags.UntrustedRoot;
458456
}
459457

460-
private X509ChainElement BuildElement(X509Certificate2 cert, int dwStatus)
458+
private X509ChainStatus[] BuildChainElementStatuses(X509Certificate2? cert, int dwStatus)
461459
{
462460
if (dwStatus == 0)
463461
{
464-
return new X509ChainElement(cert, Array.Empty<X509ChainStatus>(), "");
462+
return Array.Empty<X509ChainStatus>();
465463
}
466464

467465
List<X509ChainStatus> statuses = new List<X509ChainStatus>();
@@ -499,7 +497,7 @@ private X509ChainElement BuildElement(X509Certificate2 cert, int dwStatus)
499497
}
500498
}
501499

502-
return new X509ChainElement(cert, statuses.ToArray(), "");
500+
return statuses.ToArray();
503501
}
504502

505503
private readonly struct X509ChainErrorMapping

0 commit comments

Comments
 (0)
Please sign in to comment.