ln.http/ln.http/CertificateStore.cs

20 lines
661 B
C#

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()
{
}
public virtual void AddCertificate(X509Certificate certificate) => _cache.Add(certificate.Subject, certificate);
public virtual bool TryGetCertificate(string hostname, out X509Certificate certificate) =>
_cache.TryGetValue(String.Format("CN={0}", hostname), out certificate);
public virtual void RemoveCertificate(string hostname) => _cache.Remove(hostname);
}