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

标签 wcf authentication azure ssl certificate

我正在尝试为我的 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

enter image description here

我已将其放入我的设置

enter image description here

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

enter image description here

然而,一旦我发布它,它仍然不起作用。这是我在服务模型的 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 元素。

关于wcf - 在 Azure 托管的 WCF 服务中找不到 X.509 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32444389/

相关文章:

http认证缓存

powershell - 在 Runbook 中包含 runbook.ps1 脚本

azure - 无法使用 SPARK 在 Synapse Lake 数据库中创建架构

visual-studio - 如何在 Microsoft Azure 中解压缩大小为 900mb 的文件?

c# - 获取 "Could not establish secure channel for SSL/TLS with authority"即使 ServerCertificateValidationCallback 返回 true

silverlight - WCF 和 Silverlight 4 的另一个 "The maximum string content length quota (8192) has been exceeded while reading XML data."问题

c# - C# 和 C++ 之间可以传输什么类型的数据

c# - WCF从客户端发送int[]到服务器

Android:在设备上存储一个 bool 值

java - Spring安全登录总是200