Skip to content

Commit 12acd3e

Browse files
committed
netsh wrap
1 parent 6332df9 commit 12acd3e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/BenchmarksApps/TLS/HttpSys/NetShWrapper.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public static void DisableHttpSysMutualTls(string ipPort)
1515
Console.WriteLine("Disabled http.sys settings for mTLS");
1616
}
1717

18-
public static bool HttpSysCertBindingExists(string ipPort)
18+
public static void Show()
1919
{
20-
return true;
20+
ExecuteNetShCommand("http show sslcert", alwaysLogOutput: true);
2121
}
2222

2323
public static void EnableHttpSysMutualTls(string ipPort)
@@ -43,7 +43,7 @@ public static void EnableHttpSysMutualTls(string ipPort)
4343
Console.WriteLine("Configured http.sys settings for mTLS");
4444
}
4545

46-
private static void ExecuteNetShCommand(string command)
46+
private static void ExecuteNetShCommand(string command, bool alwaysLogOutput = false)
4747
{
4848
ProcessStartInfo processInfo = new ProcessStartInfo("netsh", command)
4949
{
@@ -58,6 +58,11 @@ private static void ExecuteNetShCommand(string command)
5858
string output = process.StandardOutput.ReadToEnd();
5959
process.WaitForExit();
6060

61+
if (alwaysLogOutput)
62+
{
63+
Console.WriteLine(output);
64+
}
65+
6166
if (process.ExitCode != 0)
6267
{
6368
throw new InvalidOperationException($"netsh command execution failure: {output}");

src/BenchmarksApps/TLS/HttpSys/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
var builder = WebApplication.CreateBuilder(args);
55
builder.Logging.ClearProviders();
66

7-
Console.WriteLine($"args: {string.Join(" ", args)}");
8-
Console.WriteLine();
9-
107
var writeCertValidationEventsToConsole = bool.TryParse(builder.Configuration["certValidationConsoleEnabled"], out var certValidationConsoleEnabled) && certValidationConsoleEnabled;
8+
var httpSysLoggingEnabled = bool.TryParse(builder.Configuration["httpSysLogs"], out var httpSysLogsEnabled) && httpSysLogsEnabled;
119
var statsEnabled = bool.TryParse(builder.Configuration["statsEnabled"], out var connectionStatsEnabledConfig) && connectionStatsEnabledConfig;
1210
var mTlsEnabled = bool.TryParse(builder.Configuration["mTLS"], out var mTlsEnabledConfig) && mTlsEnabledConfig;
1311
var tlsRenegotiationEnabled = bool.TryParse(builder.Configuration["tlsRenegotiation"], out var tlsRenegotiationEnabledConfig) && tlsRenegotiationEnabledConfig;
@@ -51,6 +49,8 @@
5149

5250
void OnShutdown()
5351
{
52+
Console.WriteLine("Application shutdown started.");
53+
5454
try
5555
{
5656
NetShWrapper.DisableHttpSysMutualTls(ipPort: httpsIpPort);
@@ -106,6 +106,12 @@ void OnShutdown()
106106
}
107107

108108
await app.StartAsync();
109+
110+
if (httpSysLoggingEnabled)
111+
{
112+
NetShWrapper.Show();
113+
}
114+
109115
Console.WriteLine("Application Info:");
110116
if (mTlsEnabled)
111117
{

0 commit comments

Comments
 (0)