# Summary

Class: | WireMock.HttpsCertificate.ClientCertificateHelper
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\HttpsCertificate\ClientCertificateHelper.cs
Covered lines: | 0
Uncovered lines: | 17
Coverable lines: | 17
Total lines: | 42
Line coverage: | 0%
Branch coverage: | 0%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
GetCertificate(...) | 0 | 0 | 0 | 0

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\HttpsCertificate\ClientCertificateHelper.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.IO;`
|  | `3` |  | `using System.Security.Cryptography.X509Certificates;`
|  | `4` |  | ``
|  | `5` |  | `namespace WireMock.HttpsCertificate`
|  | `6` |  | `{`
|  | `7` |  | `internal static class ClientCertificateHelper`
|  | `8` |  | `{`
|  | `9` |  | `public static X509Certificate2 GetCertificate(string thumbprintOrSubjectName)`
| 0 | `10` |  | `{`
| 0 | `11` |  | `X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);`
|  | `12` |  | `try`
| 0 | `13` |  | `{`
|  | `14` |  | `// Certificate must be in the local machine store`
| 0 | `15` |  | `certStore.Open(OpenFlags.ReadOnly);`
|  | `16` |  | ``
|  | `17` |  | `// Attempt to find by thumbprint first`
| 0 | `18` |  | `var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjec`
| 0 | `19` |  | `if (matchingCertificates.Count == 0)`
| 0 | `20` |  | `{`
|  | `21` |  | `// Fallback to subject name`
| 0 | `22` |  | `matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubje`
| 0 | `23` |  | `if (matchingCertificates.Count == 0)`
| 0 | `24` |  | `{`
|  | `25` |  | `// No certificates matched the search criteria.`
| 0 | `26` |  | `throw new FileNotFoundException("No certificate found with specified Thumbprint or SubjectName."`
|  | `27` |  | `}`
| 0 | `28` |  | `}`
|  | `29` |  | `// Use the first matching certificate.`
| 0 | `30` |  | `return matchingCertificates[0];`
|  | `31` |  | `}`
|  | `32` |  | `finally`
| 0 | `33` |  | `{`
|  | `34` |  | `#if NETSTANDARD || NET46`
| 0 | `35` |  | `certStore.Dispose();`
|  | `36` |  | `#else`
|  | `37` |  | `certStore.Close();`
|  | `38` |  | `#endif`
| 0 | `39` |  | `}`
| 0 | `40` |  | `}`
|  | `41` |  | `}`
|  | `42` |  | `}`

# Methods/Properties

GetCertificate(System.String)