Skip to content

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

@hymccord

Description

@hymccord

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

  • 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions