Skip to content

Commit

Permalink
Use list patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Aug 2, 2023
1 parent e3b5ebd commit dd96eb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Src/Fido2/Metadata/ConformanceMetadataRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,8 @@ public async Task<MetadataBLOBPayload> DeserializeAndValidateBlob(string rawBLOB
if (rootCert.Thumbprint.Equals(certChain.ChainElements[^1].Certificate.Thumbprint, StringComparison.Ordinal) &&
// and that the number of elements in the chain accounts for what was in x5c plus the root we added
certChain.ChainElements.Count == (x5cRawKeys.Length + 1) &&
// and that the root cert has exactly one status listed against it
certChain.ChainElements[^1].ChainElementStatus.Length == 1 &&
// and that that status is a status of exactly UntrustedRoot
certChain.ChainElements[^1].ChainElementStatus[0].Status == X509ChainStatusFlags.UntrustedRoot)
// and that the root cert has exactly one status with the value of UntrustedRoot
certChain.ChainElements[^1].ChainElementStatus is [ { Status: X509ChainStatusFlags.UntrustedRoot } ])
{
// if we are good so far, that is a good sign
certChainIsValid = true;
Expand Down
6 changes: 2 additions & 4 deletions Src/Fido2/Metadata/Fido2MetadataServiceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ private async Task<MetadataBLOBPayload> DeserializeAndValidateBlobAsync(string r
if (rootCert.Thumbprint == certChain.ChainElements[^1].Certificate.Thumbprint &&
// and that the number of elements in the chain accounts for what was in x5c plus the root we added
certChain.ChainElements.Count == (x5cRawKeys.Length + 1) &&
// and that the root cert has exactly one status listed against it
certChain.ChainElements[^1].ChainElementStatus.Length == 1 &&
// and that that status is a status of exactly UntrustedRoot
certChain.ChainElements[^1].ChainElementStatus[0].Status == X509ChainStatusFlags.UntrustedRoot)
// and that the root cert has exactly one status with the value of UntrustedRoot
certChain.ChainElements[^1].ChainElementStatus is [ { Status: X509ChainStatusFlags.UntrustedRoot } ])
{
// if we are good so far, that is a good sign
certChainIsValid = true;
Expand Down

0 comments on commit dd96eb2

Please sign in to comment.