ln.http/ln.http/CertificateStore.cs

20 lines
661 B
C#
Raw Permalink Normal View History

2024-04-21 23:25:05 +02:00
using System;
using System.Security.Cryptography.X509Certificates;
using ln.collections;
namespace ln.http;
public class CertificateStore
{
private Cache<string, X509Certificate> _cache = new Cache<string, X509Certificate>();
public CertificateStore()
{
}
2024-04-21 17:22:24 +02:00
public virtual void AddCertificate(X509Certificate certificate) => _cache.Add(certificate.Subject, certificate);
public virtual bool TryGetCertificate(string hostname, out X509Certificate certificate) =>
2024-04-21 23:25:05 +02:00
_cache.TryGetValue(String.Format("CN={0}", hostname), out certificate);
2024-04-21 17:22:24 +02:00
public virtual void RemoveCertificate(string hostname) => _cache.Remove(hostname);
}