Skip to content

Commit 59afb4a

Browse files
committed
enable htpt.sys hostname!
1 parent 65cf5dc commit 59afb4a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

scenarios/rejection.benchmarks.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ jobs:
2222
mTLS: false # enables settings on http.sys to negotiate client cert on connections
2323
tlsRenegotiation: false # enables client cert validation
2424
certPublicKeyLength: 2048
25+
httpSysUrlPrefix: "" # enables host header validation on http.sys layer
2526
# debug settings
2627
certValidationConsoleEnabled: false
2728
httpSysLogs: false
2829
statsEnabled: false
2930
logRequestDetails: false
30-
arguments: "--urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --logRequestDetails {{logRequestDetails}}"
31+
arguments: "--urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --logRequestDetails {{logRequestDetails}} --httpSysUrlPrefix {{httpSysUrlPrefix}}"
3132

3233
kestrelServer:
3334
source:
@@ -77,6 +78,8 @@ scenarios:
7778
httpsys-hostheader-mismatch:
7879
application:
7980
job: httpSysServer
81+
variables:
82+
httpSysUrlPrefix: "https://testserver.local:5000"
8083
load:
8184
job: httpclient
8285
variables:

src/BenchmarksApps/TLS/HttpSys/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
var tlsRenegotiationEnabled = bool.TryParse(builder.Configuration["tlsRenegotiation"], out var tlsRenegotiationEnabledConfig) && tlsRenegotiationEnabledConfig;
1313
var certPublicKeySpecified = int.TryParse(builder.Configuration["certPublicKeyLength"], out var certPublicKeyConfig);
1414
var certPublicKeyLength = certPublicKeySpecified ? certPublicKeyConfig : 2048;
15+
var urlPrefix = builder.Configuration["httpSysUrlPrefix"];
1516

1617
// endpoints
1718
var listeningEndpoints = builder.Configuration["urls"] ?? "https://localhost:5000/";
@@ -38,10 +39,12 @@
3839
// meaning client can send a certificate, but it can be explicitly requested by server as well (renegotiation)
3940
options.ClientCertificateMethod = ClientCertificateMethod.AllowRenegotation;
4041

41-
foreach (var listeningEndpoint in listeningEndpoints.Split(";"))
42+
if (!string.IsNullOrEmpty(urlPrefix))
4243
{
43-
options.UrlPrefixes.Add(listeningEndpoints);
44-
Console.WriteLine("Added allowed url-prefix: " + listeningEndpoint);
44+
// Specific "hostname" to listen on.
45+
// This turns on host validation on http.sys layer
46+
options.UrlPrefixes.Add(urlPrefix);
47+
Console.WriteLine("Set specific url-prefix for Http.Sys: " + urlPrefix);
4548
}
4649
});
4750
#pragma warning restore CA1416 // Can be launched only on Windows (HttpSys)

src/BenchmarksApps/TLS/HttpSys/appsettings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"Default": "Information",
55
"Microsoft.AspNetCore": "Warning"
66
}
7-
},
8-
"AllowedHosts": "*"
7+
}
98
}

0 commit comments

Comments
 (0)