Skip to content

Commit 4d7a79a

Browse files
authored
Change HttpSys default client cert mode to Allow Cert #14840 (#23162)
1 parent 724c2e7 commit 4d7a79a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Servers/HttpSys/src/FeatureContext.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,18 @@ async Task<X509Certificate2> ITlsConnectionFeature.GetClientCertificateAsync(Can
333333
{
334334
if (IsNotInitialized(Fields.ClientCertificate))
335335
{
336-
_clientCert = await Request.GetClientCertificateAsync(cancellationToken);
336+
var method = _requestContext.Server.Options.ClientCertificateMethod;
337+
if (method != ClientCertificateMethod.NoCertificate)
338+
{
339+
// Check if a cert was already available on the connection.
340+
_clientCert = Request.ClientCertificate;
341+
}
342+
343+
if (_clientCert == null && method == ClientCertificateMethod.AllowRenegotation)
344+
{
345+
_clientCert = await Request.GetClientCertificateAsync(cancellationToken);
346+
}
347+
337348
SetInitialized(Fields.ClientCertificate);
338349
}
339350
return _clientCert;

src/Servers/HttpSys/src/HttpSysOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public string RequestQueueName
5555
public RequestQueueMode RequestQueueMode { get; set; }
5656

5757
/// <summary>
58-
/// Indicates how client certificates should be populated. The default is to allow renegotation.
58+
/// Indicates how client certificates should be populated. The default is to allow a certificate without renegotiation.
5959
/// This does not change the netsh 'clientcertnegotiation' binding option which will need to be enabled for
6060
/// ClientCertificateMethod.AllowCertificate to resolve a certificate.
6161
/// </summary>
62-
public ClientCertificateMethod ClientCertificateMethod { get; set; } = ClientCertificateMethod.AllowRenegotation;
62+
public ClientCertificateMethod ClientCertificateMethod { get; set; } = ClientCertificateMethod.AllowCertificate;
6363

6464
/// <summary>
6565
/// The maximum number of concurrent accepts.

0 commit comments

Comments
 (0)