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 bf8ee151cb75c..53b588d37b50e 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 @@ -247,7 +247,6 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran _ocspResponse = ret; _ocspExpiration = expiration; _nextDownload = nextCheckA < nextCheckB ? nextCheckA : nextCheckB; - _pendingDownload = null; break; } } @@ -256,6 +255,16 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran ArrayPool.Shared.Return(rentedChars.Array!); GC.KeepAlive(TargetCertificate); 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; } }