未验证 提交 1e97f7c5 编写于 作者: J Jeremy Barton 提交者: GitHub

Make ConnectWithRevocation_StapledOcsp more resilient to being slow

上级 4c6b53b0
......@@ -5,6 +5,7 @@
using System.Net;
using System.Net.Sockets;
using System.Net.Test.Common;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates.Tests.Common;
......@@ -184,8 +185,36 @@ await using (SslStream tlsServer = new SslStream(serverStream))
if (revocationMode == X509RevocationMode.Offline)
{
// Give the OCSP response a better chance to finish.
await Task.Delay(200);
if (offlineContext.GetValueOrDefault(false))
{
// Add a delay just to show we're not winning because of race conditions.
await Task.Delay(200);
}
else
{
if (!OperatingSystem.IsLinux())
{
throw new InvalidOperationException(
"This test configuration uses reflection and is only defined for Linux.");
}
FieldInfo pendingDownloadTaskField = typeof(SslStreamCertificateContext).GetField(
"_pendingDownload",
BindingFlags.Instance | BindingFlags.NonPublic);
if (pendingDownloadTaskField is null)
{
throw new InvalidOperationException("Cannot find the pending download field.");
}
Task download = (Task)pendingDownloadTaskField.GetValue(serverOpts.ServerCertificateContext);
// If it's null, it should mean it has already finished. If not, it might not have.
if (download is not null)
{
await download;
}
}
}
}
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册