Skip to content

Commit 6fbdfce

Browse files
committed
more options to control
1 parent 05cdbae commit 6fbdfce

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/BenchmarksApps/TLS/HttpSys/ConfigurationHelpers.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ internal static class ConfigurationHelpers
66
{
77
public static SslProtocols ParseSslProtocols(string? supportedTlsVersions)
88
{
9-
var protocols = SslProtocols.Tls12; // default it TLS 1.2
10-
if (string.IsNullOrEmpty(supportedTlsVersions))
9+
var protocols = SslProtocols.None;
10+
if (supportedTlsVersions is null)
1111
{
1212
return protocols;
1313
}
1414

15-
protocols = SslProtocols.None;
1615
foreach (var version in supportedTlsVersions.Split(','))
1716
{
1817
switch (version.Trim().ToLower())

src/BenchmarksApps/TLS/HttpSys/RegistryController.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public static void ShowRegistryKeys()
3333

3434
public static void EnableTls(SslProtocols sslProtocols)
3535
{
36+
Console.WriteLine($"Configuring tls to match {sslProtocols}");
37+
3638
if (sslProtocols.HasFlag(SslProtocols.Tls12))
3739
{
3840
EnableTls12();
@@ -44,7 +46,19 @@ public static void EnableTls(SslProtocols sslProtocols)
4446
return;
4547
}
4648

47-
throw new ArgumentOutOfRangeException(nameof(sslProtocols), "Unsupported TLS protocol version. Only TLS1.2 and TLS1.3 are supported.");
49+
Console.WriteLine("Enabling all TLS - no option specified");
50+
EnableAll();
51+
}
52+
53+
private static void EnableAll()
54+
{
55+
// Enable TLS1.2
56+
SetRegistryValue(TLS12SubKey, "DisabledByDefault", value: 0, valueToOverride: 1);
57+
SetRegistryValue(TLS12SubKey, "Enabled", value: 1, valueToOverride: 0);
58+
59+
// Enable TLS1.3
60+
SetRegistryValue(TLS13SubKey, "DisabledByDefault", value: 0, valueToOverride: 1);
61+
SetRegistryValue(TLS13SubKey, "Enabled", value: 1, valueToOverride: 0);
4862
}
4963

5064
private static void EnableTls12()

0 commit comments

Comments
 (0)