Skip to content

Commit d7fd8f9

Browse files
committed
registry!
1 parent 64a4d28 commit d7fd8f9

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

scenarios/tls.benchmarks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ jobs:
2222
# debug purpose settings
2323
certValidationConsoleEnabled: false
2424
httpSysLogs: false
25+
tlsRegistryLogs: false
2526
statsEnabled: false
2627
logRequestInfo: false
27-
arguments: "--urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --tlsProtocols {{tlsProtocols}} --logRequestInfo {{logRequestInfo}}"
28+
arguments: "--urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --tlsProtocols {{tlsProtocols}} --logRequestInfo {{logRequestInfo}} --tlsRegistryLogs {{tlsRegistryLogs}}"
2829

2930
kestrelServer:
3031
source:

src/BenchmarksApps/TLS/HttpSys/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
builder.Logging.ClearProviders();
88

99
var writeCertValidationEventsToConsole = bool.TryParse(builder.Configuration["certValidationConsoleEnabled"], out var certValidationConsoleEnabled) && certValidationConsoleEnabled;
10-
var httpSysLoggingEnabled = bool.TryParse(builder.Configuration["httpSysLogs"], out var httpSysLogsEnabled) && httpSysLogsEnabled;
10+
var httpSysLogsEnabled = bool.TryParse(builder.Configuration["httpSysLogs"], out var httpSysLogsConfig) && httpSysLogsConfig;
11+
var tlsRegistryLogsEnabled = bool.TryParse(builder.Configuration["tlsRegistryLogs"], out var tlsRegistryLogsConfig) && tlsRegistryLogsConfig;
1112
var logRequestInfo = bool.TryParse(builder.Configuration["logRequestInfo"], out var logRequestInfoConfig) && logRequestInfoConfig;
1213
var statsEnabled = bool.TryParse(builder.Configuration["statsEnabled"], out var connectionStatsEnabledConfig) && connectionStatsEnabledConfig;
1314

@@ -90,7 +91,9 @@ void OnShutdown()
9091
if (!logged)
9192
{
9293
logged = true;
94+
Console.WriteLine("[RequestInfo]");
9395
Console.WriteLine("TLS Protocol: " + context.Features.Get<ITlsHandshakeFeature>()?.Protocol);
96+
Console.WriteLine("---");
9497
}
9598

9699
await next();
@@ -131,7 +134,11 @@ void OnShutdown()
131134

132135
await app.StartAsync();
133136

134-
if (httpSysLoggingEnabled)
137+
if (tlsRegistryLogsEnabled)
138+
{
139+
RegistryController.ShowRegistryKeys();
140+
}
141+
if (httpSysLogsEnabled)
135142
{
136143
NetShWrapper.Show();
137144
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Text;
2+
using Microsoft.Win32;
3+
4+
namespace HttpSys
5+
{
6+
public static class RegistryController
7+
{
8+
private const string TLS12Key = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server";
9+
private const string TLS13Key = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters";
10+
11+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "benchmark only runs on windows")]
12+
public static void ShowRegistryKeys()
13+
{
14+
var strBuilder = new StringBuilder("Registry TLS settings: \n");
15+
16+
var tls12Enabled = Registry.GetValue(TLS12Key, "Enabled", "not defined");
17+
strBuilder.AppendLine("\tTLS 1.2: " + tls12Enabled?.ToString());
18+
19+
var tls13Enabled = Registry.GetValue(TLS13Key, "EnableHTTP3", "not defined");
20+
strBuilder.AppendLine("\tTLS 1.3: " + tls12Enabled?.ToString());
21+
22+
Console.WriteLine(strBuilder.ToString());
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)