/// <summary>
    /// Store a <see cref="AuthenticateResult"/> for the connection and certificate
    /// </summary>
    /// <param name="context">The HttpContext.</param>
    /// <param name="certificate">The certificate.</param>
    /// <param name="result">the <see cref="AuthenticateResult"/></param>
    public void Put(HttpContext context, X509Certificate2 certificate, AuthenticateResult result)
    {
        // Never cache longer than 30 minutes
        var absoluteExpiration = _clock.UtcNow.Add(TimeSpan.FromMinutes(30));
        var notAfter           = certificate.NotAfter.ToUniversalTime();

        if (notAfter < absoluteExpiration)
        {
            absoluteExpiration = notAfter;
        }
        _cache.Set(ComputeKey(certificate), result.Clone(), new MemoryCacheEntryOptions()
                   .SetSize(1)
                   .SetSlidingExpiration(_options.CacheEntryExpiration)
                   .SetAbsoluteExpiration(absoluteExpiration));
    }
Пример #2
0
 /// <summary>
 /// Store a <see cref="AuthenticateResult"/> for the connection and certificate
 /// </summary>
 /// <param name="context">The HttpContext.</param>
 /// <param name="certificate">The certificate.</param>
 /// <param name="result">the <see cref="AuthenticateResult"/></param>
 public void Put(HttpContext context, X509Certificate2 certificate, AuthenticateResult result)
 => _cache.Set(ComputeKey(certificate), result.Clone(), new MemoryCacheEntryOptions()
               .SetSize(1).SetSlidingExpiration(_options.CacheEntryExpiration).SetAbsoluteExpiration(certificate.NotAfter));