在 Azure 中托管的 WCF 服务中找不到 X.509 证书

Cannot find the X.509 certificate in WCF service hosted in Azure

我正在尝试为我的 WCF 服务创建一个基于证书的身份验证平台,我已经按照所有教程制作了我的证书并将其安装在 IIS 中,并且在本地 运行 一切正常,但是一旦我将它发布到 Azure,我就会得到异常

Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'CN=tempCert'.

我已经将 .pvk 上传到 azure

我已经把它放在我的设置里了

而且我确保将其添加到网站的应用程序设置中

但是发布之后还是不行。这是我在 Web.Config 文件中针对服务模型

的配置
  <system.serviceModel>
<services>
  <service name="clientSecurity">
    <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding"
      name="wsHttpEndpoint" contract="uConnect.Web.IUConnectService" />
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security>
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client />
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <serviceCertificate findValue="CN=tempCert" x509FindType="FindBySubjectName" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>

正如我所提到的,当我在本地 运行 它时它工作得很好,它只会在我将它发布到 azure 时抛出异常。欢迎任何帮助,因为我已经尝试解决这个问题一段时间了。

您需要在 Azure WebApps 中指定证书存储 - 这些在 currentUser 中加载。将 storeLocation="CurrentUser" storeName="My" 添加到 serviceCertificate 元素。