Recently moved to a new work machine where FIPS is enabled and got an System.InvalidOperationException from the MD5CryptoServiceProvider when trying to instantiate via MD5.Create in the utility method GetMD5Hash (code).
Repro
Have a windows machine where FIPS is enforced. How to enable
Open a binlog
Right click a project node > Preprocess
Exception is thrown and you can't view the XML file
Upgrade to .NetFramework to 4.8 so the exception isn't thrown anymore
Add <AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=false" /> to the runtime section of App.config if planning to stay on .NetFramework 4.7.2
Description
Recently moved to a new work machine where FIPS is enabled and got an
System.InvalidOperationException
from theMD5CryptoServiceProvider
when trying to instantiate viaMD5.Create
in the utility methodGetMD5Hash
(code).Repro
Version: 2.1.844
.NetFramework 4.7.2
Resolution
I'm more than willing to fix this as it's a very simple fix. Documentation here (https://github.com/microsoft/dotnet/blob/b5f52bf00618f7ccd62b04a5a2fa94b71241a88a/Documentation/compatibility/cryptographicexception-not-thrown-in-fips-mode.md) states that .NetFramework 4.7.2 will throw by default but this was relaxed in .NetFramework 4.8
Either,
<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=false" />
to theruntime
section ofApp.config
if planning to stay on .NetFramework 4.7.2