Skip to content

Commit 754adee

Browse files
committed
address PR comments + change port to high-value (no intersection with other tests)
1 parent 2f5437e commit 754adee

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

scenarios/tls.benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ scenarios:
5858
tlsRenegotiation: true # enables client cert validation
5959
httpSysLogs: false # only for debug purposes
6060
certValidationConsoleEnabled: false # only for debug purposes
61+
serverPort: 30000 # IMPORTANT: not to intersect with other tests
6162
load:
6263
job: httpclient
6364
variables:

src/BenchmarksApps/TLS/HttpSys/NetShWrapper.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ namespace HttpSys
55
{
66
public static class NetShWrapper
77
{
8+
public static void DisableHttpSysMutualTlsIfExists(string ipPort)
9+
{
10+
try
11+
{
12+
DisableHttpSysMutualTls(ipPort);
13+
}
14+
catch
15+
{
16+
// ignore
17+
}
18+
}
19+
820
public static void DisableHttpSysMutualTls(string ipPort)
921
{
1022
Console.WriteLine("Disabling mTLS for http.sys");
@@ -70,9 +82,10 @@ private static void ExecuteNetShCommand(string command, bool alwaysLogOutput = f
7082
}
7183

7284
#pragma warning disable SYSLIB0057 // Type or member is obsolete
73-
private static X509Certificate2 LoadCertificate() => File.Exists("testCert.pfx")
74-
? new X509Certificate2("testCert.pfx", "testPassword", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable)
75-
: new X509Certificate2("../testCert.pfx", "testPassword", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
85+
private static X509Certificate2 LoadCertificate()
86+
=> File.Exists("testCert.pfx")
87+
? X509CertificateLoader.LoadPkcs12FromFile("testCert.pfx", "testPassword", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable)
88+
: X509CertificateLoader.LoadPkcs12FromFile("../testCert.pfx", "testPassword", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable)
7689
#pragma warning restore SYSLIB0057 // Type or member is obsolete
7790
}
7891
}

src/BenchmarksApps/TLS/HttpSys/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ void OnShutdown()
6464

6565
try
6666
{
67+
// if not executed, following command (enable http.sys mutual tls) will fail because binding exists
68+
NetShWrapper.DisableHttpSysMutualTlsIfExists(ipPort: httpsIpPort);
69+
6770
NetShWrapper.EnableHttpSysMutualTls(ipPort: httpsIpPort);
6871
}
6972
catch

0 commit comments

Comments
 (0)