Skip to content

【Azure 应用服务】应用代码中需要使用客户端证书访问服务接口,部署在应用服务后报错不能找到证书(Cannot find the X.509 certificate)

LuBu0505 edited this page Feb 24, 2023 · 1 revision

问题描述

在应用中,需要访问另一个服务接口,这个接口需要使用客户端证书进行认证。在代码中使用 System.Security.Cryptography.X509Certificates 加载Window系统中 Current User\My 下的证书。 image.png

然后把证书通过App Service门户页面上传。 image.png

但是,在访问应用时候,还是报错不能发现证书指纹

Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'CurrentUser', FindType 'FindByThumbprint', FindValue 'AAC*********************9F63EB' **

问题分析

根据对官方文档分析,得出一个结论,为了使运行在App Service实例上的应用能够读取到实例(如 Windows)中的证书,必须配置一个应用设置。**WEBSITE_LOAD_CERTIFICATES **

  • 如果只有一个证书,就为 WEBSITE_LOAD_CERTIFICATES  设置 证书指纹值。
  • 如果有多个证书,WEBSITE_LOAD_CERTIFICATES  设置为  * 

问题即可解决!

参考资料

使证书可供访问 : https://docs.azure.cn/zh-cn/app-service/configure-ssl-certificate-in-code#make-the-certificate-accessible

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

分类: 【Azure 应用服务】

标签: WEBSITE_LOAD_CERTIFICATESCannot find the X.509 certificate

Clone this wiki locally