繁体   English   中英

从 base64 编码字符串创建证书在 Azure Function 中失败

[英]Creating Certificate from base64 encoded string failing in Azure Function

我正在尝试从 base64 编码字符串创建X509Certificate2 我已将此代码添加到示例 Azure function 中。 在本地代码有效,我可以从 bas364 编码字符串创建证书 object,但是在发布到 Azure 时出现异常
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException at Internal.Cryptography.Pal.CertificatePal.FilterPFXStore遵循https://github.com/dotnet/runtime/issues/30658我将应用服务计划保留为“(P1v2:1)”,这不是共享。

Use WEBSITE_LOAD_CERTIFICATES app setting in your azure function the specified certificates accessible to your Windows hosted app in the Windows certificate store, in Current_User\Your_user .

在您的代码中,通过证书指纹访问证书。 certificateThumbprint = "<your certificate thumbprint>";

注意:应用服务将证书路径注入 Windows 容器。 像变量WEBSITE_PRIVATE_CERTS_PATHWEBSITE_INTERMEDIATE_CERTS_PATHWEBSITE_PUBLIC_CERTS_PATHWEBSITE_ROOT_CERTS_PATH 确保您必须使用环境变量引用证书路径,而不是对证书路径进行硬编码。

如果仍然存在,您也面临同样的问题,您可以在您的应用中添加WEBSITE_LOAD_USER_PROFILE=1应用设置。 该错误表示特定用户无法访问该证书。 它将解决您的问题。

请参阅此处了解更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM