未验证 提交 a3960a81 编写于 作者: T Tomas Weinfurt 提交者: GitHub

avoid allocation X509Chain if there is no certificate (#74616)

上级 b27b2988
......@@ -43,12 +43,14 @@ internal static partial class CertificateValidationPal
{
QueryContextRemoteCertificate(securityContext, out remoteContext);
if (remoteContext != null && !remoteContext.IsInvalid)
if (remoteContext == null || remoteContext.IsInvalid)
{
remoteContext.DangerousAddRef(ref gotReference);
result = new X509Certificate2(remoteContext.DangerousGetHandle());
return null;
}
remoteContext.DangerousAddRef(ref gotReference);
result = new X509Certificate2(remoteContext.DangerousGetHandle());
if (retrieveChainCertificates)
{
chain ??= new X509Chain();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册