File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
src/BenchmarksApps/TLS/HttpSys Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ public static void DisableHttpSysMutualTls(string ipPort)
15
15
Console . WriteLine ( "Disabled http.sys settings for mTLS" ) ;
16
16
}
17
17
18
- public static bool HttpSysCertBindingExists ( string ipPort )
18
+ public static void Show ( )
19
19
{
20
- return true ;
20
+ ExecuteNetShCommand ( "http show sslcert" , alwaysLogOutput : true ) ;
21
21
}
22
22
23
23
public static void EnableHttpSysMutualTls ( string ipPort )
@@ -43,7 +43,7 @@ public static void EnableHttpSysMutualTls(string ipPort)
43
43
Console . WriteLine ( "Configured http.sys settings for mTLS" ) ;
44
44
}
45
45
46
- private static void ExecuteNetShCommand ( string command )
46
+ private static void ExecuteNetShCommand ( string command , bool alwaysLogOutput = false )
47
47
{
48
48
ProcessStartInfo processInfo = new ProcessStartInfo ( "netsh" , command )
49
49
{
@@ -58,6 +58,11 @@ private static void ExecuteNetShCommand(string command)
58
58
string output = process . StandardOutput . ReadToEnd ( ) ;
59
59
process . WaitForExit ( ) ;
60
60
61
+ if ( alwaysLogOutput )
62
+ {
63
+ Console . WriteLine ( output ) ;
64
+ }
65
+
61
66
if ( process . ExitCode != 0 )
62
67
{
63
68
throw new InvalidOperationException ( $ "netsh command execution failure: { output } ") ;
Original file line number Diff line number Diff line change 4
4
var builder = WebApplication . CreateBuilder ( args ) ;
5
5
builder . Logging . ClearProviders ( ) ;
6
6
7
- Console . WriteLine ( $ "args: { string . Join ( " " , args ) } ") ;
8
- Console . WriteLine ( ) ;
9
-
10
7
var writeCertValidationEventsToConsole = bool . TryParse ( builder . Configuration [ "certValidationConsoleEnabled" ] , out var certValidationConsoleEnabled ) && certValidationConsoleEnabled ;
8
+ var httpSysLoggingEnabled = bool . TryParse ( builder . Configuration [ "httpSysLogs" ] , out var httpSysLogsEnabled ) && httpSysLogsEnabled ;
11
9
var statsEnabled = bool . TryParse ( builder . Configuration [ "statsEnabled" ] , out var connectionStatsEnabledConfig ) && connectionStatsEnabledConfig ;
12
10
var mTlsEnabled = bool . TryParse ( builder . Configuration [ "mTLS" ] , out var mTlsEnabledConfig ) && mTlsEnabledConfig ;
13
11
var tlsRenegotiationEnabled = bool . TryParse ( builder . Configuration [ "tlsRenegotiation" ] , out var tlsRenegotiationEnabledConfig ) && tlsRenegotiationEnabledConfig ;
51
49
52
50
void OnShutdown ( )
53
51
{
52
+ Console . WriteLine ( "Application shutdown started." ) ;
53
+
54
54
try
55
55
{
56
56
NetShWrapper . DisableHttpSysMutualTls ( ipPort : httpsIpPort ) ;
@@ -106,6 +106,12 @@ void OnShutdown()
106
106
}
107
107
108
108
await app . StartAsync ( ) ;
109
+
110
+ if ( httpSysLoggingEnabled )
111
+ {
112
+ NetShWrapper . Show ( ) ;
113
+ }
114
+
109
115
Console . WriteLine ( "Application Info:" ) ;
110
116
if ( mTlsEnabled )
111
117
{
You can’t perform that action at this time.
0 commit comments