<legend id='JMxRK'><style id='JMxRK'><dir id='JMxRK'><q id='JMxRK'></q></dir></style></legend>
        <bdo id='JMxRK'></bdo><ul id='JMxRK'></ul>

      <small id='JMxRK'></small><noframes id='JMxRK'>

      <tfoot id='JMxRK'></tfoot>
    1. <i id='JMxRK'><tr id='JMxRK'><dt id='JMxRK'><q id='JMxRK'><span id='JMxRK'><b id='JMxRK'><form id='JMxRK'><ins id='JMxRK'></ins><ul id='JMxRK'></ul><sub id='JMxRK'></sub></form><legend id='JMxRK'></legend><bdo id='JMxRK'><pre id='JMxRK'><center id='JMxRK'></center></pre></bdo></b><th id='JMxRK'></th></span></q></dt></tr></i><div id='JMxRK'><tfoot id='JMxRK'></tfoot><dl id='JMxRK'><fieldset id='JMxRK'></fieldset></dl></div>

      RSACryptoServiceProvider CryptographicException 系统找不到

      时间:2023-06-02
    2. <i id='FYOeo'><tr id='FYOeo'><dt id='FYOeo'><q id='FYOeo'><span id='FYOeo'><b id='FYOeo'><form id='FYOeo'><ins id='FYOeo'></ins><ul id='FYOeo'></ul><sub id='FYOeo'></sub></form><legend id='FYOeo'></legend><bdo id='FYOeo'><pre id='FYOeo'><center id='FYOeo'></center></pre></bdo></b><th id='FYOeo'></th></span></q></dt></tr></i><div id='FYOeo'><tfoot id='FYOeo'></tfoot><dl id='FYOeo'><fieldset id='FYOeo'></fieldset></dl></div>
          <bdo id='FYOeo'></bdo><ul id='FYOeo'></ul>
          • <legend id='FYOeo'><style id='FYOeo'><dir id='FYOeo'><q id='FYOeo'></q></dir></style></legend>

            <small id='FYOeo'></small><noframes id='FYOeo'>

                  <tbody id='FYOeo'></tbody>
              1. <tfoot id='FYOeo'></tfoot>
              2. 本文介绍了RSACryptoServiceProvider CryptographicException 系统找不到 ASP.NET 下指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个使用 RSACryptoServiceProvider 使用已知私钥(存储在变量中)解密某些数据的应用程序.

                I have an application which is making use of the RSACryptoServiceProvider to decrypt some data using a known private key (stored in a variable).

                当 IIS 应用程序池配置为使用网络服务时,一切运行正常.

                When the IIS Application Pool is configured to use Network Service, everything runs fine.

                但是,当我们配置 IIS 应用程序池以在不同的身份下运行代码时,我们会得到以下信息:

                However, when we configure the IIS Application Pool to run the code under a different Identity, we get the following:

                System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
                
                   at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
                   at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
                   at System.Security.Cryptography.RSA.FromXmlString(String xmlString)
                

                代码是这样的:

                byte[] input; 
                byte[] output; 
                string private_key_xml; 
                
                var provider = new System.Cryptography.RSACryptoServiceProvider(this.m_key.Key_Size);
                provider.FromXmlString(private_key_xml); // Fails Here when Application Pool Identity != Network Service
                
                ouput = provider.Decrypt(input, false); // False = Use PKCS#1 v1.5 Padding
                

                有一些资源试图通过说明您应该授予用户对机器密钥存储的读取权限来回答这个问题 - 但是没有明确的答案来解决这个问题.

                There are resources which attempt to answer it by stating that you should give the user read access to the machine key store - however there is no definitive answer to solve this issue.

                环境:IIS 6.0、Windows Server 2003 R2、.NET 3.5 SP1

                Environment: IIS 6.0, Windows Server 2003 R2, .NET 3.5 SP1

                推荐答案

                确实需要这样的代码

                CspParameters _cpsParameter;
                RSACryptoServiceProvider RSAProvider;
                
                _cpsParameter = new CspParameters();
                _cpsParameter.Flags = CspProviderFlags.UseMachineKeyStore;
                
                RSAProvider = new RSACryptoServiceProvider(1024, _cpsParameter); 
                

                以下用户需要访问该文件夹:C:Documents and SettingsAll UsersApplication dataMicrosoftCryptoRSAMachineKeys

                The following users need access to the folder: C:Documents and SettingsAll UsersApplication dataMicrosoftCryptoRSAMachineKeys

                1. IIS 用户帐户(匿名)
                2. 您在 web.config 设置中用于模拟您的应用程序的用户帐户.

                所以现在它对我来说很好.

                So now it is working fine for me.

                这篇关于RSACryptoServiceProvider CryptographicException 系统找不到 ASP.NET 下指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:.NET 加密许可证密钥? 下一篇:RSACryptoServiceProvider(.NET 的 RSA)可以使用 SHA256 进行

                相关文章

                最新文章

                1. <legend id='nK0Jf'><style id='nK0Jf'><dir id='nK0Jf'><q id='nK0Jf'></q></dir></style></legend>
                    <bdo id='nK0Jf'></bdo><ul id='nK0Jf'></ul>
                  <tfoot id='nK0Jf'></tfoot>

                  <small id='nK0Jf'></small><noframes id='nK0Jf'>

                2. <i id='nK0Jf'><tr id='nK0Jf'><dt id='nK0Jf'><q id='nK0Jf'><span id='nK0Jf'><b id='nK0Jf'><form id='nK0Jf'><ins id='nK0Jf'></ins><ul id='nK0Jf'></ul><sub id='nK0Jf'></sub></form><legend id='nK0Jf'></legend><bdo id='nK0Jf'><pre id='nK0Jf'><center id='nK0Jf'></center></pre></bdo></b><th id='nK0Jf'></th></span></q></dt></tr></i><div id='nK0Jf'><tfoot id='nK0Jf'></tfoot><dl id='nK0Jf'><fieldset id='nK0Jf'></fieldset></dl></div>