CryptographicException"未找到对象"打开密钥库

chr*_*tok 1 vb.net asp.net private-key

我遇到了一个错误,我正试图打开一个p12密钥库.这在开发中工作正常,但是当我编译并移动到生产服务器时,会抛出"找不到对象"错误.

关于我所知道的全部内容是因为密钥库文件不存在.当我从服务器中删除存储时,错误消息更改为"系统找不到指定的文件".

任何想法可能是什么问题或如何调试?不幸的是,我无法介入,因为这是编译代码.

这是跟踪:

System.Security.Cryptography.CryptographicException: Object was not found.

   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
   at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
   at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password)
   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
Run Code Online (Sandbox Code Playgroud)

chr*_*tok 9

很快就解决了这个问题.这是决议:

  • 在IIS上,打开应用程序池高级设置.
  • 将加载用户配置文件设置为TRUE
  • 将Identity设置为LocalService
  • 回收应用程序池