Skip to content

Commit

Permalink
more options to control
Browse files Browse the repository at this point in the history
  • Loading branch information
DeagleGross committed Jan 20, 2025
1 parent 05cdbae commit 6fbdfce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/BenchmarksApps/TLS/HttpSys/ConfigurationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ internal static class ConfigurationHelpers
{
public static SslProtocols ParseSslProtocols(string? supportedTlsVersions)
{
var protocols = SslProtocols.Tls12; // default it TLS 1.2
if (string.IsNullOrEmpty(supportedTlsVersions))
var protocols = SslProtocols.None;
if (supportedTlsVersions is null)
{
return protocols;
}

protocols = SslProtocols.None;
foreach (var version in supportedTlsVersions.Split(','))
{
switch (version.Trim().ToLower())
Expand Down
16 changes: 15 additions & 1 deletion src/BenchmarksApps/TLS/HttpSys/RegistryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public static void ShowRegistryKeys()

public static void EnableTls(SslProtocols sslProtocols)
{
Console.WriteLine($"Configuring tls to match {sslProtocols}");

if (sslProtocols.HasFlag(SslProtocols.Tls12))
{
EnableTls12();
Expand All @@ -44,7 +46,19 @@ public static void EnableTls(SslProtocols sslProtocols)
return;
}

throw new ArgumentOutOfRangeException(nameof(sslProtocols), "Unsupported TLS protocol version. Only TLS1.2 and TLS1.3 are supported.");
Console.WriteLine("Enabling all TLS - no option specified");
EnableAll();
}

private static void EnableAll()
{
// Enable TLS1.2
SetRegistryValue(TLS12SubKey, "DisabledByDefault", value: 0, valueToOverride: 1);
SetRegistryValue(TLS12SubKey, "Enabled", value: 1, valueToOverride: 0);

// Enable TLS1.3
SetRegistryValue(TLS13SubKey, "DisabledByDefault", value: 0, valueToOverride: 1);
SetRegistryValue(TLS13SubKey, "Enabled", value: 1, valueToOverride: 0);
}

private static void EnableTls12()
Expand Down

0 comments on commit 6fbdfce

Please sign in to comment.