【问题标题】:CryptographicException no line number in stacktraceCryptographicException 在堆栈跟踪中没有行号
【发布时间】:2014-10-22 19:48:26
【问题描述】:

我在使用通过 Visual Studio 的身份和访问工具配置的 ADFS 2.0 和 MVC 4 应用程序(在 IIS 7.5 上运行的应用程序)的事件查看器中遇到以下异常

Exception type: CryptographicException 
Exception message: Key not valid for use in specified state.

我无法重现该错误。它在我们的公共网站上间歇性发生,我通过事件查看器看到它。

尽管这是一个单一的服务器部署并且不涉及农场(除了 ADFS 有一个主服务器和一个代理服务器),只是为了它,我通过阅读这篇文章启用了网络农场 cookie http://www.cloudidentity.com/blog/2013/01/28/running-wif-based-apps-in-windows-azure-web-sites-4/

上面的异常消失了,但是这个异常现在以相同的间歇频率出现:

Exception type: CryptographicException 
Exception message: Error occurred during a cryptographic operation.

事件查看器的堆栈跟踪中没有行号。此应用程序中的任何其他异常都会给出行号,而这个没有。如果我没有行号,如何找出导致此异常的代码段?就像我说的我无法重现它,所以没有使用调试,或者是吗?

编辑

我注意到 web.config 中的 keys 节点下有两个元素。我不需要一个吗?

<system.identityModel>
    <identityConfiguration> 
        <issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
            <authority name="http://our-FS-server/adfs/services/trust">
              <keys>
                 <add thumbprint="abcd" />
                 <add thumbprint="efgh" />
              </keys>
            </authority>
        </issuerNameRegistry>
    </identityConfiguration> 
</system.identityModel>

【问题讨论】:

    标签: c# asp.net-mvc cryptography adfs2.0


    【解决方案1】:

    看起来 web.config 中的额外键条目是原因。我删除了其中一个,并且在 3 小时内没有看到异常。早些时候,该异常出现的频率要高得多。所以也许解决方案是像 Vittorio Bertocci 在他的博客文章中指出的那样启用网络农场 cookie http://www.cloudidentity.com/blog/2013/01/28/running-wif-based-apps-in-windows-azure-web-sites-4/

    在我的情况下,它只花了更长的时间,因为我有那个额外的钥匙。

    【讨论】:

      猜你喜欢
      • 2018-12-03
      • 2014-09-30
      • 2017-01-30
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2016-01-28
      • 2011-02-19
      • 1970-01-01
      相关资源
      最近更新 更多