feat(batch9): implement f1 auth and dirstore foundations

This commit is contained in:
Joseph Doherty
2026-02-28 12:12:50 -05:00
parent 26e4729e8b
commit 78d222a86d
6 changed files with 212 additions and 38 deletions

View File

@@ -14,7 +14,6 @@
// Adapted from server/reload.go in the NATS server Go source.
using System.Reflection;
using System.Security.Cryptography;
using System.Text.Json;
using ZB.MOM.NatsNet.Server.Auth;
using ZB.MOM.NatsNet.Server.Internal;
@@ -1331,26 +1330,7 @@ public sealed partial class NatsServer
private static bool MatchesPinnedCert(ClientConnection client, PinnedCertSet? pinnedCerts)
{
if (pinnedCerts == null || pinnedCerts.Count == 0)
return true;
var certificate = client.GetTlsCertificate();
if (certificate == null)
return false;
byte[] keyBytes;
try
{
keyBytes = certificate.PublicKey.ExportSubjectPublicKeyInfo();
}
catch
{
keyBytes = certificate.GetPublicKey();
}
var hash = SHA256.HashData(keyBytes);
var hex = Convert.ToHexString(hash).ToLowerInvariant();
return pinnedCerts.Contains(hex);
return client.MatchesPinnedCert(pinnedCerts);
}
}