Cats.CertificateTransparency
5.0.0
dotnet add package Cats.CertificateTransparency --version 5.0.0
NuGet\Install-Package Cats.CertificateTransparency -Version 5.0.0
<PackageReference Include="Cats.CertificateTransparency" Version="5.0.0" />
<PackageVersion Include="Cats.CertificateTransparency" Version="5.0.0" />
<PackageReference Include="Cats.CertificateTransparency" />
paket add Cats.CertificateTransparency --version 5.0.0
#r "nuget: Cats.CertificateTransparency, 5.0.0"
#:package Cats.CertificateTransparency@5.0.0
#addin nuget:?package=Cats.CertificateTransparency&version=5.0.0
#tool nuget:?package=Cats.CertificateTransparency&version=5.0.0
Certificate Transparency for .NET
C# .NET port of,
Install-Package Cats.CertificateTransparency
The library is designed to be dependency injection friendly, every service class has a matching interface. However, to get things up and running quickly there is also a static Instance class which will construct lazy singletons for both ILogListService and CertificateTransparencyVerifier.
If you want to provide a custom list of included and excluded domains to these static instances you must first call Instance.InitDomains. By default validation will be enabled for all TLS secured domains.
Instance.InitDomains(new [] { "*.google.com", "microsoft.com" }, new [] { "nuget.org" });
Examples
.NET
var client = new HttpClient(new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = (request, certificate, chain, sslPolicyErrors) =>
{
var certificateChain = chain.ChainElements.OfType<X509ChainElement>().Select(i => i.Certificate).ToList();
var certificateVerifier = Cats.CertificateTransparency.Instance.CertificateTransparencyVerifier;
var ctValueTask = certificateVerifier.IsValidAsync(request.RequestUri.Host, certificateChain, CancellationToken.None);
var ctResult = ctValueTask.IsCompleted
? ctValueTask.Result
: ctValueTask.AsTask().Result;
return ctResult.IsValid;
}
});
Android
bool VerifyCtResult(string hostname, IList<DotNetX509Certificate> certificateChain, CtVerificationResult result)
{
// any extra checks or logging you might want to add
return result.IsValid;
}
// optionally pass in a function to manually handle the transparency result
var httpHandler = new Cats.CertificateTransparency.CatsAndroidClientHandler(VerifyCtResult);
var client = new HttpClient(httpHandler);
iOS
There is currently no platform specific implementation for iOS. Certificate transparency is already enabled since iOS 12.1.1, however, it can be disabled per domain via a property list setting NSRequiresCertificateTransparency.
If you are keen you could use the CertificateVerifier to build your own HttpClientHandler, similar to the included Android implementation.
Contributions
Any contributions are welcome! Especially extra test cases!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net10.0-android36.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cats.CertificateTransparency:
| Package | Downloads |
|---|---|
|
LemonMarkets
Community C# Library #2 for Lemon Markets |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Updated to net10.0
- Removed BouncyCastle dependency