File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
src/BenchmarksApps/TLS/HttpSys Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,13 @@ jobs:
17
17
variables :
18
18
mTLS : false # enables settings on http.sys to negotiate client cert on connections
19
19
tlsRenegotiation : false # enables client cert validation
20
+ tlsProtocols : " tls12"
21
+ # debug purpose settings
20
22
certValidationConsoleEnabled : false
21
23
httpSysLogs : false
22
24
statsEnabled : false
23
- tlsProtocols : " tls12 "
24
- arguments : " --urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --tlsProtocols {{tlsProtocols}}"
25
+ logRequestInfo : false
26
+ arguments : " --urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --httpSysLogs {{httpSysLogs}} --tlsProtocols {{tlsProtocols}} --logRequestInfo {{logRequestInfo}} "
25
27
26
28
kestrelServer :
27
29
source :
Original file line number Diff line number Diff line change 8
8
9
9
var writeCertValidationEventsToConsole = bool . TryParse ( builder . Configuration [ "certValidationConsoleEnabled" ] , out var certValidationConsoleEnabled ) && certValidationConsoleEnabled ;
10
10
var httpSysLoggingEnabled = bool . TryParse ( builder . Configuration [ "httpSysLogs" ] , out var httpSysLogsEnabled ) && httpSysLogsEnabled ;
11
+ var logRequestInfo = bool . TryParse ( builder . Configuration [ "logRequestInfo" ] , out var logRequestInfoConfig ) && logRequestInfoConfig ;
11
12
var statsEnabled = bool . TryParse ( builder . Configuration [ "statsEnabled" ] , out var connectionStatsEnabledConfig ) && connectionStatsEnabledConfig ;
13
+
12
14
var mTlsEnabled = bool . TryParse ( builder . Configuration [ "mTLS" ] , out var mTlsEnabledConfig ) && mTlsEnabledConfig ;
13
15
var tlsRenegotiationEnabled = bool . TryParse ( builder . Configuration [ "tlsRenegotiation" ] , out var tlsRenegotiationEnabledConfig ) && tlsRenegotiationEnabledConfig ;
14
16
var listeningEndpoints = builder . Configuration [ "urls" ] ?? "https://localhost:5000/" ;
@@ -78,6 +80,23 @@ void OnShutdown()
78
80
}
79
81
}
80
82
83
+ if ( logRequestInfo )
84
+ {
85
+ Console . WriteLine ( "Registered request logging middleware" ) ;
86
+ var logged = false ;
87
+
88
+ app . Use ( async ( context , next ) =>
89
+ {
90
+ if ( ! logged )
91
+ {
92
+ logged = true ;
93
+ Console . WriteLine ( "TLS Protocol: " + context . Features . Get < ITlsHandshakeFeature > ( ) ? . Protocol ) ;
94
+ }
95
+
96
+ await next ( ) ;
97
+ } ) ;
98
+ }
99
+
81
100
if ( tlsRenegotiationEnabled )
82
101
{
83
102
// this is an http.sys middleware to get a cert
@@ -89,7 +108,6 @@ void OnShutdown()
89
108
{
90
109
if ( writeCertValidationEventsToConsole )
91
110
{
92
- Console . WriteLine ( "Protocol: " + context . Features . Get < ITlsHandshakeFeature > ( ) ? . Protocol ) ;
93
111
Console . WriteLine ( $ "No client certificate provided. Fetching for connection { context . Connection . Id } ") ;
94
112
}
95
113
You can’t perform that action at this time.
0 commit comments