Skip to content

Commit 962bcf6

Browse files
authored
Suppress codeql warning and fix typo (#5030)
* Suppress CodeQL false alarm for use of weak cryptography. Also fix caller logic according to the context. * Fix suspected typo.
1 parent bfb35ff commit 962bcf6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/System.ServiceModel.NetNamedPipe/src/System/ServiceModel/Channels/PipeConnectionInitiator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,18 +385,18 @@ public static string BuildSharedMemoryName(string hostName, string path, bool gl
385385
return builder.ToString();
386386
}
387387

388-
internal const string UseSha1InMsmqEncryptionAlgorithmString = "Switch.System.ServiceModel.UseSha1InMsmqEncryptionAlgorithm";
389-
internal static bool s_useSha1InPipeConnectionGetHashAlgorithm = AppContext.TryGetSwitch(UseSha1InMsmqEncryptionAlgorithmString, out bool enabled) && enabled;
388+
internal const string UseSha1InPipeConnectionGetHashAlgorithmString = "Switch.System.ServiceModel.UseSha1InPipeConnectionGetHashAlgorithm";
389+
internal static bool s_useSha1InPipeConnectionGetHashAlgorithm = AppContext.TryGetSwitch(UseSha1InPipeConnectionGetHashAlgorithmString, out bool enabled) && enabled;
390390

391391
private static HashAlgorithm GetHashAlgorithm()
392392
{
393393
if (s_useSha1InPipeConnectionGetHashAlgorithm)
394394
{
395-
return SHA256.Create();
395+
return SHA1.Create(); // CodeQL [SM02196] Here SHA1 is not used for cryptographic purposes, it's for compatibility.
396396
}
397397
else
398398
{
399-
return SHA1.Create();
399+
return SHA256.Create();
400400
}
401401
}
402402

0 commit comments

Comments
 (0)