静态企业网站模板,泛解析对网站的影响,做数学网站,旅游app推广营销策略使用 C# 中 RSA#xff08;System.Security.Cryptography.RSA#xff09; 加密算法生成证书签名进行身份验证#xff0c;在 VS2022 开发工具本地运行应用程序一切正常。
但将应用程序部署到远程服务器#xff08;如#xff1a;Azure App Services#xff09;#xff0c…使用 C# 中 RSASystem.Security.Cryptography.RSA 加密算法生成证书签名进行身份验证在 VS2022 开发工具本地运行应用程序一切正常。
但将应用程序部署到远程服务器如Azure App Services生成签名时产生如下错误信息
System.Security.Cryptography.CryptographicException: The system cannot find the file specified.at System.Security.Cryptography.CngKey.Import(ReadOnlySpan1 keyBlob, String curveName, CngKeyBlobFormat format, CngProvider provider)at System.Security.Cryptography.CngPkcs8.ImportPkcs8(ReadOnlySpan1 keyBlob)at System.Security.Cryptography.CngPkcs8.ImportPkcs8PrivateKey(ReadOnlySpan1 source, Int32 bytesRead)at System.Security.Cryptography.RSACng.ImportPkcs8PrivateKey(ReadOnlySpan1 source, Int32 bytesRead)
这很可能是因为 Cryptographic Service 提供程序试图在用户存储区中存储或加载证书的密钥并且由于配置文件不可用因此加密上下文不可用。
由于应用程序服务Azure App Serivces默认没有开启加载用户配置文件设定。
解决上述问题
可在Azure应用程序服务 配置 Application settings增加 WEBSITE_LOAD_USER_PROFILE 1 的应用配置信息即可。 若应用程序部署在 Windows IIS 服务器上则可以在应用程序池开启“加载用户配置文件”设定即可设定步骤如下
打开IIS管理器。进入应用程序池管理页面点选中要设定的应用程序池。在右边“操作”模块下点击“高级设置...”或鼠标右键选择“高级设置...”。在“进程模型Process Model”节点将“加载用户配置文件Load User Profile”设为 True如下截图