【发布时间】:2021-02-25 11:14:28
【问题描述】:
我尝试从此代码生成密钥
CngKey key = CngKey.Import(Convert.FromBase64String(privateKey), CngKeyBlobFormat.Pkcs8PrivateBlob);
它在本地运行良好,但是当我在我的 Azure 应用服务中部署时。 它给了我这个错误:
System.Security.Cryptography.CryptographicException:系统找不到指定的文件。 在 System.Security.Cryptography.NCryptNative.ImportKey(SafeNCryptProviderHandle 提供程序,字节 [] keyBlob,字符串格式) 在 System.Security.Cryptography.CngKey.Import(Byte[] keyBlob, String curveName, CngKeyBlobFormat 格式, CngProvider provider)
我在配置中添加了 WEBSITE_LOAD_USER_PROFILE,值为“1”,但没有任何区别。
谢谢
【问题讨论】:
-
您是否发布了应用程序?只有在构建和部署机器上都安装了相同版本的 net(包括更新)时,c# 代码才能在另一台机器上运行。如果您没有相同的版本,则必须发布。
-
是的,我的申请已发布
-
是否有可执行文件在 bin 文件夹中的任何 dll 文件。可能需要在exe文件所在的deploy机器上添加dll。
-
它是一个 Web 应用程序,我有一台构建机器将包部署在 azure 应用服务上
-
您的构建包可能缺少需要的 dll。
标签: c# azure security cryptography private-key