如何在 Azure 上部署的云服务上引用 x.509 证书?

How to reference x.509 certificates on a cloud service deployed on azure?

在 Azure 上部署 Web 服务后,我在引用 x.509 证书时遇到问题。我得到的错误是:

Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindByThumbprint', FindValue 'd50d00762ab0b5bfa2ccd51122360e89ff5db55e'

我尝试了各种 StoreName 和 Location 排列,但没有成功。 我的部分配置如下:

<behaviors>
      <endpointBehaviors>
        <behavior name="ClientCredentialsBehavior">
          <clientCredentials>
            <clientCertificate findValue="D50D00762AB0B5BFA2CCD51122360E89FF5DB55E"  storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindByThumbprint"/>
            <serviceCertificate>
              <defaultCertificate findValue="E194EBAAFBE5129D097795751127D21577293A87" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindByThumbprint"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>

如何解决 azure 上的这个错误。请帮助我,我现在已经花了几个小时试图解决这个问题。谢谢。

要解决您遇到的问题,请确保证书已上传到云服务中,并且该证书已在云服务配置文件中引用 (csdef/cscfg)。请参阅此 link 了解如何操作:https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-configure-ssl-certificate#step-2-modify-the-service-definition-and-configuration-files.

解释来了:).

如您所知,云服务是 PaaS 产品。因此,您需要告诉 Fabric Controller(它负责创建您的 VM、安装您的应用程序并进行所有配置更改)您的应用程序需要使用在云服务中上传的证书。

您告诉 Fabric 控制器的方式是在服务定义 file/service 配置文件中指定证书详细信息(如证书指纹)。您还会告诉您希望 Fabric Controller 在 Cloud Service VM 上的哪个证书存储中安装证书。

Fabric Controller 获取此信息后,在创建 VM 时,它会转到已上传到云服务中的证书,根据指纹找到匹配的证书,并将该证书安装到您的云服务 VM 中。由于您没有在服务 definition/configuration 文件中指定它,因此证书从未安装在您的云服务 VM 上。