Skip to content

Commit 9741b65

Browse files
authored
Merge pull request #86 from microsoft/20250207_SQLCHECK_TLSpartialkeyfix
Update Collectors.cs
2 parents f66e21a + 7792936 commit 9741b65

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

SQLCheck/SQLCheck/Collectors.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,17 @@ public static void CollectTLS(DataSet ds)
860860
TLS["TLSVersion"] = tlsVersion;
861861
defVal = tlsInfo.GetComputerDefault(tlsVersion, cs);
862862
TLS["Defaultvalue"] = defVal;
863-
temp = Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "Enabled", "");
863+
if (Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "Enabled", null) == null)
864+
temp = null;
865+
else
866+
temp = Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "Enabled", "");
864867
if (tlsVersion == "TLS 1.3" && temp != null) isTLS13KeyPresent = true;
865868
enVal = temp == null ? "" : ((temp.ToInt() != 0) ? $"True " : "False") + $" (0x{temp.ToInt().ToString("X8")})" + CheckTLS(tlsVersion, "Enabled", temp.ToInt());
866869
TLS["EnabledValue"] = enVal;
867-
temp = Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "DisabledByDefault", "");
870+
if (Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "DisabledByDefault", null) == null)
871+
temp = null;
872+
else
873+
temp = Registry.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\{tlsVersion}\{cs}", "DisabledByDefault", "");
868874
if (tlsVersion == "TLS 1.3" && temp != null) isTLS13KeyPresent = true;
869875
disVal = temp == null ? "" : ((temp.ToInt() != 0) ? $"True " : "False") + $" (0x{temp.ToInt().ToString("X8")})" + CheckTLS(tlsVersion, "DisabledByDefault", temp.ToInt());
870876
TLS["DisabledByDefaultValue"] = disVal;

0 commit comments

Comments
 (0)