KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.41k stars 188 forks source link

MD5 causes cryptographic exception if FIPS is enabled on Windows #701

Closed hymccord closed 10 months ago

hymccord commented 10 months ago

Description

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

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,

  1. Upgrade to .NetFramework to 4.8 so the exception isn't thrown anymore
  2. 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
KirillOsenkov commented 10 months ago

Thanks, would you mind sending a PR with the app.config change?

hymccord commented 10 months ago

Thanks for the quick reply. Sent PR. Tested to make sure it works as well.