Skip to content

Commit 3eb695a

Browse files
committed
Recover from failed OCSP download. (dotnet#96448)
* Recover from failed OCSP check. * Add 5s back-off after failed OCSP querry
1 parent 84eb5d0 commit 3eb695a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran
245245
_ocspResponse = ret;
246246
_ocspExpiration = expiration;
247247
_nextDownload = nextCheckA < nextCheckB ? nextCheckA : nextCheckB;
248-
_pendingDownload = null;
249248
break;
250249
}
251250
}
@@ -254,6 +253,16 @@ partial void AddRootCertificate(X509Certificate2? rootCertificate, ref bool tran
254253
ArrayPool<char>.Shared.Return(rentedChars.Array!);
255254
GC.KeepAlive(Certificate);
256255
GC.KeepAlive(caCert);
256+
257+
_pendingDownload = null;
258+
if (ret == null)
259+
{
260+
// all download attempts failed, don't try again for 5 seconds.
261+
// Note that if server does not send OCSP staples, clients may still
262+
// contact OCSP responders directly.
263+
_nextDownload = DateTimeOffset.UtcNow.AddSeconds(5);
264+
_ocspExpiration = _nextDownload;
265+
}
257266
return ret;
258267
}
259268
}

0 commit comments

Comments
 (0)