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

fix assert in ssl options clone (#72326)

* fix assert in ssl options clone

* add CertificateChainPolicy

* remove extra assert
上级 c94c3f96
......@@ -13,9 +13,9 @@ internal static partial class CertificateHelper
{
private const string ClientAuthenticationOID = "1.3.6.1.5.5.7.3.2";
internal static X509Certificate2? GetEligibleClientCertificate(X509CertificateCollection candidateCerts)
internal static X509Certificate2? GetEligibleClientCertificate(X509CertificateCollection? candidateCerts)
{
if (candidateCerts.Count == 0)
if (candidateCerts == null || candidateCerts.Count == 0)
{
return null;
}
......@@ -26,9 +26,9 @@ internal static partial class CertificateHelper
return GetEligibleClientCertificate(certs);
}
internal static X509Certificate2? GetEligibleClientCertificate(X509Certificate2Collection candidateCerts)
internal static X509Certificate2? GetEligibleClientCertificate(X509Certificate2Collection? candidateCerts)
{
if (candidateCerts.Count == 0)
if (candidateCerts == null || candidateCerts.Count == 0)
{
return null;
}
......
......@@ -19,6 +19,7 @@ public static SslClientAuthenticationOptions ShallowClone(this SslClientAuthenti
AllowRenegotiation = options.AllowRenegotiation,
ApplicationProtocols = options.ApplicationProtocols != null ? new List<SslApplicationProtocol>(options.ApplicationProtocols) : null,
CertificateRevocationCheckMode = options.CertificateRevocationCheckMode,
CertificateChainPolicy = options.CertificateChainPolicy,
CipherSuitesPolicy = options.CipherSuitesPolicy,
ClientCertificates = options.ClientCertificates,
EnabledSslProtocols = options.EnabledSslProtocols,
......
......@@ -222,7 +222,7 @@ public ClientCertificateOption ClientCertificateOptions
#else
ThrowForModifiedManagedSslOptionsIfStarted();
_clientCertificateOptions = value;
_underlyingHandler.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => CertificateHelper.GetEligibleClientCertificate(ClientCertificates)!;
_underlyingHandler.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) => CertificateHelper.GetEligibleClientCertificate(_underlyingHandler.SslOptions.ClientCertificates)!;
#endif
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册