diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs index 2c01cea48e208..cd3d48b7ab09c 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs @@ -266,7 +266,6 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran _ocspResponse = ret; _ocspExpiration = expiration; _nextDownload = nextCheckA < nextCheckB ? nextCheckA : nextCheckB; - _pendingDownload = null; break; } } @@ -279,6 +278,16 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran GC.KeepAlive(_privateIntermediateCertificates); GC.KeepAlive(_rootCertificate); GC.KeepAlive(caCert); + + _pendingDownload = null; + if (ret == null) + { + // all download attempts failed, don't try again for 5 seconds. + // Note that if server does not send OCSP staples, clients may still + // contact OCSP responders directly. + _nextDownload = DateTimeOffset.UtcNow.AddSeconds(5); + _ocspExpiration = _nextDownload; + } return ret; } }