首页 新闻 赞助 找找看

System.Security.Cryptography.CryptographicException拒绝访问

0
[已解决问题] 解决于 2012-09-20 11:30

System.Security.Cryptography.CryptographicException拒绝访问做个快钱支付的  本地可以但是到服务器提示这个错误

问题补充:

发现其他服务器可以      但是就有一台不行   到底是怎么一回事啊     有谁碰到类似的情况 

程序员编程日记的主页 程序员编程日记 | 初学一级 | 园豆:6
提问于:2012-04-05 18:02
< >
分享
最佳答案
0

试试:

当 RSACryptoProvider 创建了密钥文件但由于权限不足而无法删除该密钥文件时,会导致此错误。
此问题只会发生在应用层。
 
若要更正此错误,请确认代理服务帐户对“Documents and Settings”文件夹中 RSA 计算机密钥文件夹(例如,C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA)的“完全控制”权限设置为“允许”。

http://msdn.microsoft.com/zh-cn/library/ms400681.aspx

奖励园豆:5
玉开 | 大侠五级 |园豆:8822 | 2012-04-05 18:14

还是不行

程序员编程日记 | 园豆:6 (初学一级) | 2012-04-05 18:17

@lyl6796910: 

你设置的账户是network service吗?

玉开 | 园豆:8822 (大侠五级) | 2012-04-05 18:18

@lyl6796910: 

试一下:

http://stackoverflow.com/questions/3504760/sitecore-system-security-cryptography-cryptographicexception

It basically says to add this in your global.asax:

publicvoidApplication_Start(){
 
System.Security.Cryptography.RSACryptoServiceProvider.UseMachineKeyStore=true;
 
System.Security.Cryptography.DSACryptoServiceProvider.UseMachineKeyStore=true;
}
玉开 | 园豆:8822 (大侠五级) | 2012-04-05 18:20

@玉开: 设置了

程序员编程日记 | 园豆:6 (初学一级) | 2012-04-05 18:22

@玉开: 还是不行啊

程序员编程日记 | 园豆:6 (初学一级) | 2012-04-05 18:28

@lyl6796910: 

把异常的堆栈存起来,然后看是否能从源码中找到问题。需要反编译.net类库

玉开 | 园豆:8822 (大侠五级) | 2012-04-06 08:36

@玉开: 

<html>
    <head>
        <title>拒绝访问。<br></title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>

    <body bgcolor="white">

            <span><H1>“/”应用程序中的服务器错误。<hr width=100% size=1 color=silver></H1>

            <h2> <i>拒绝访问。<br></i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> 说明: </b>执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

            <br><br>

            <b> 异常详细信息: </b>System.Security.Cryptography.CryptographicException: 拒绝访问。<br><br><br>

            <b>源错误:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code>

只有在调试模式下进行编译时,生成此未处理异常的源代码才会显示出来。若要启用此功能,请执行以下步骤之一,然后请求 URL: <br><br>1. 在产生错误的文件的顶部添加一条“Debug=true”指令。例如: <br><br> &nbsp;&nbsp;&lt;%@ Page Language=&quot;C#&quot; Debug=&quot;true&quot; %&gt;<br><br>或:<br><br>2. 将以下的节添加到应用程序的配置文件中:<br><br>&lt;configuration&gt;<br> &nbsp;&nbsp;&nbsp;&lt;system.web&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;compilation debug=&quot;true&quot;/&gt;<br> &nbsp;&nbsp;&nbsp;&lt;/system.web&gt;<br>&lt;/configuration&gt;<br><br> 请注意,第二个步骤将使给定应用程序中的所有文件在调试模式下进行编译;第一个步骤仅使该特定文件在调试模式下进行编译。<br><br>重要事项: 以调试模式运行应用程序一定会产生内存/性能系统开销。在部署到生产方案之前,应确保应用程序调试已禁用。</code>

                  </td>
               </tr>
            </table>

            <br>

            <b>堆栈跟踪:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">
               <tr>
                  <td>
                      <code><pre>

[CryptographicException: 拒绝访问。
]
   System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) +33
   System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle&amp; pCertCtx) +0
   System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +228
   System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags) +136
   Send.Page_Load(Object sender, EventArgs e) +680
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
</pre></code>

                  </td>
               </tr>
            </table>

            <br>

            <hr width=100% size=1 color=silver>

            <b>版本信息:</b>&nbsp;Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42

            </font>

    </body>
</html>
<!--
[CryptographicException]: 拒绝访问。

   在 System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
   在 System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
   在 System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
   在 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
   在 Send.Page_Load(Object sender, EventArgs e)
   在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   在 System.Web.UI.Control.OnLoad(EventArgs e)
   在 System.Web.UI.Control.LoadRecursive()
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: 引发类型为“System.Web.HttpUnhandledException”的异常。
   在 System.Web.UI.Page.HandleError(Exception e)
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在 System.Web.UI.Page.ProcessRequest()
   在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   在 System.Web.UI.Page.ProcessRequest(HttpContext context)
   在 ASP.send_aspx.ProcessRequest(HttpContext context)
   在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->

程序员编程日记 | 园豆:6 (初学一级) | 2012-04-06 09:51

@lyl6796910: 

你那台服务器上的.net版本是什么,在iis站点上设置.net版本了吗?我用2.0和4.0版本的dll,都没有X509Utils._LoadCertFromFile方法。

玉开 | 园豆:8822 (大侠五级) | 2012-04-06 12:37

@lyl6796910: 

建议你把出问题这台服务器上的framework升级到最新版本试试

玉开 | 园豆:8822 (大侠五级) | 2012-04-06 12:39
其他回答(1)
0

我也遇到这种情况了,搞了2个晚上还没搞定,准备重装干净的win7 系统

Kyw08 | 园豆:204 (菜鸟二级) | 2012-07-05 00:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册