sha*_*oth 96 .net c# iis-7 application-pool x509certificate
我遇到了以下问题.
我运行以下代码
var binaryData = File.ReadAllBytes(pathToPfxFile);
var cert = new X509Certificate2(binaryData, password);
Run Code Online (Sandbox Code Playgroud)
在两个过程中.其中一个进程运行,LOCAL_SYSTEM并且此代码成功.另一个在IIS中在属于"Users"本地组的本地用户帐户下运行,在那里我得到以下异常:
System.Security.Cryptography.CryptographicException
Object was not found.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)
//my code here
Run Code Online (Sandbox Code Playgroud)
所以我用Google搜索了一下,找到了一个类似问题的答案.我尝试启用LoadUserProfile应用程序池,现在可以正常运行.
问题是我没有得到我设置时会发生LoadUserProfile什么以及可能产生的后果.我的意思是,如果它是一个"好"的东西那么为什么它不是默认"开启",为什么它毕竟在那里?
当我LoadUserProfile在IIS池中设置时会发生什么,它会产生什么负面影响?
vcs*_*nes 109
我的意思是,如果它是一个"好"的东西那么为什么它不是默认"开启",为什么它毕竟在那里?
IIS 6从未加载用户配置文件.我认为默认情况下这是关闭以保持行为一致,并且管理员必须选择加入它.
我尝试为应用程序池启用LoadUserProfile,现在可以正常工作.
这很可能是因为Windows加密服务提供程序试图在用户存储中存储或加载证书的密钥,并且由于配置文件不可用,因此无法使用加密上下文.请注意,该Load User Profile设置仅适用于用户帐户.NETWORK SERVICE和ApplicationPoolIdentity等服务帐户有特殊处理.
在IIS池中设置LoadUserProfile时会发生什么
好吧,加载了用户配置文件.这包括他们的加密存储,环境变量,如%TEMP%,以及其他.
LoadUserProfile当AppPool启动时,IIS会调用它最终归结为什么.
会有什么负面影响?
它可能会破坏与IIS 6上运行的应用程序的向后兼容性,该应用程序未加载用户配置文件.加载环境变量.例如,当Load User Profile为Load时,%TEMP%环境变量为C:\Users\AccountName\AppData\Local\Temp(例如).如果是假的,那就是C:\WINDOWS\Temp.
| 归档时间: |
|
| 查看次数: |
53653 次 |
| 最近记录: |