MesAuth.SslTrustHelper
1.0.4
dotnet add package MesAuth.SslTrustHelper --version 1.0.4
NuGet\Install-Package MesAuth.SslTrustHelper -Version 1.0.4
<PackageReference Include="MesAuth.SslTrustHelper" Version="1.0.4" />
<PackageVersion Include="MesAuth.SslTrustHelper" Version="1.0.4" />
<PackageReference Include="MesAuth.SslTrustHelper" />
paket add MesAuth.SslTrustHelper --version 1.0.4
#r "nuget: MesAuth.SslTrustHelper, 1.0.4"
#:package MesAuth.SslTrustHelper@1.0.4
#addin nuget:?package=MesAuth.SslTrustHelper&version=1.0.4
#tool nuget:?package=MesAuth.SslTrustHelper&version=1.0.4
MesAuth.SslTrustHelper
SSL trust helper for self-signed server certificates used in MES applications. Supports multiple trusted domains.
Overview
Provides validated, thumbprint-based SSL trust for self-signed certificates — replacing blanket (_, _, _, _) => true callbacks with proper certificate pinning that auto-saves on first connection.
Usage
Register trusted domains
using MesAuth.SslTrust;
// Single domain
SslTrustHelper.AddTrustedDomains("domain.com");
// Multiple domains in one call
SslTrustHelper.AddTrustedDomains("domain1.com", "domain2.com");
// Certs stored as:
// {appDir}/domain1.cer
// {appDir}/domain2.cer
Wire up to HttpClient
var handler = new SocketsHttpHandler
{
SslOptions = new SslClientAuthenticationOptions
{
RemoteCertificateValidationCallback = SslTrustHelper.ValidateCertificate
}
};
Trust Logic
Checked against all registered domains in order:
| Condition | Result |
|---|---|
| OS-trusted certificate (CA-signed) | ✅ Allow |
Thumbprint matches a saved .cer |
✅ Allow |
| Same subject/CN, new thumbprint (cert renewed) | ✅ Allow + auto-save new cert |
Domain registered, no .cer yet, subject contains domain name |
✅ Allow + auto-save (first connection) |
| No domain matches | ❌ Reject |
Behavior
- First startup: no
.cerfile exists → cert auto-trusted and saved when the subject CN matches the registered domain - Normal startup:
.cerloaded at startup, validated by thumbprint on each request - Cert renewal: same CN detected → new cert auto-saved, old thumbprint replaced
- CA-signed cert:
SslPolicyErrors.None→ always trusted without a file - Multiple domains: each domain maintains its own
.cerfile independently
Certificate files
Certs are always stored in the application's base directory (AppDomain.CurrentDomain.BaseDirectory) as {domain}.cer. No configuration needed.
Logging
Uses Serilog when available (detected via reflection), falls back to Console.WriteLine. No hard Serilog dependency.
Requirements
- .NET 8, .NET 9, or .NET 10
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. 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.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MesAuth.SslTrustHelper:
| Package | Downloads |
|---|---|
|
MesAuth.Authorizer
Mes authorizer is middle-ware to verify authencation of MesAuth service |
GitHub repositories
This package is not used by any popular GitHub repositories.