Ben*_*ack 10 .net c# asp.net iis fips
我正在尝试设置一个Web应用程序,FIPSAlgorithmPolicy
以便1
在Windows注册表中设置的环境中工作(特别是HKLM/SYSTEM/CurrentControlSet/Control/Lsa).启用此标志后,对该类的任何调用MD5CryptoServiceProvider
都将导致Invalid Operation Exception
使用以下堆栈跟踪抛出:
[InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.]
System.Security.Cryptography.RijndaelManaged..ctor() +10480142
System.Web.Configuration.MachineKeySection.ConfigureEncryptionObject() +439
System.Web.Configuration.MachineKeySection.EnsureConfig() +152
System.Web.Configuration.MachineKeySection.GetEncodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32& length) +48
System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph) +381
System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph) +59
System.Web.UI.HiddenFieldPageStatePersister.Save() +89
System.Web.UI.Page.SaveAllState() +1117
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3864
Run Code Online (Sandbox Code Playgroud)
根据我在本文中读到的内容,您应该能够将以下内容添加到配置文件中以禁用算法检查:
<configuration>
<runtime>
<enforceFIPSPolicy enabled="false"/>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这通过修改其app.config在测试控制台应用程序中适用于我.但是,当修改.NET 2.0 Web应用程序的web.config时,它似乎不起作用.
对我来说有趣的是,即使我在实例化MD5CryptoServiceProvider
代码时捕获所有异常,它似乎甚至没有实现我的代码的那部分.这是我的测试应用程序中调用的代码:
protected string printSomething()
{
string toPrint = String.Empty;
try
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
toPrint = "Created algorithm.";
}
catch (Exception e)
{
toPrint = e.ToString();
}
return toPrint;
}
Run Code Online (Sandbox Code Playgroud)
这就是我访问页面时看到的内容:
所以这提出了几个问题:
<enforceFIPSPolicy enabled="false"/>
?1).您的代码不会抛出异常.ASP.NET正在做其他事情.ASP.NET正在尝试序列化ViewState; 可以通过机器密钥加密.当ASP.NET在内部执行此操作时; 它使用的RijndaelManaged
类(其不是FIPS 140兼容;以及鼓起同样;当ASP.NET尝试来加密/解密一个窗体身份验证票;它将使用计算机密钥为好.
您有一些机器密钥问题的选项.您可以使用3DES(通过将web.config中的MachineKey设置为如下所示,它将始终使用符合FIPS的实现:
<machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="3DES" decryption="3DES" />
Run Code Online (Sandbox Code Playgroud)
2).我不确定为什么你的旗子被忽略了.它不应该.如果我搞清楚,我会编辑.
请注意,MD5CryptoServiceProvider
可能仍然炸弹.MD5不是符合FIPS标准的哈希.我所知道的; 只有SHA-1和SHA-2哈希算法在.NET中.最终CryptoServiceProvider
依赖于Windows CSP 的加密函数; 这也承认了这面旗帜.另一种方法是使用BouncyCastle而不是.NET的实现,因为它不关心那个标志.
归档时间: |
|
查看次数: |
10341 次 |
最近记录: |