feat(batch9): implement f1 auth and dirstore foundations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user