【问题标题】:Wcf service throws exception: Could not establish trust relationship for the SSL/TLS secure channel with authorityWcf 服务抛出异常:无法为具有权限的 SSL/TLS 安全通道建立信任关系
【发布时间】:2016-12-11 18:23:47
【问题描述】:

我知道有很多关于堆栈溢出的问题,但没有一个是最近出现的,似乎没有完全解决我的问题。

情况如下:

我们有一个在 IIS 6.2 上运行的 web 服务。 Web 服务配置为仅接受 https 流量。网站上的绑定配置为在所有可用的 IP 地址上使用 HTTPS,在默认端口 443 上。选择的 ssl 证书是购买的专用证书。

该网站在一个专用的应用程序池中运行,有一个专用的用户

证书链安装在网络服务器上,位于以下位置的本地计算机下:

  • Root ca - 受信任的根证书颁发机构
  • 组织验证 ca - 中级认证机构
  • pfx 证书 - 个人

在 pfx 证书中,我在“管理私钥”选项中授予了专用用户读取权限。在调试时,我还授予以下帐户读取权限:

  • 网络服务
  • 你自己
  • iis_iusr

我已向 Web 服务添加了诊断程序以创建 svclog,并且还为 IIS 上的 Web 服务实例启用了日志记录。两个日志似乎都没有信息。

在解决问题时,我尝试运行本地测试客户端。为此,我需要在当前用户的个人商店中安装 *.cer 文件。

请注意,我们在网络服务器上尝试过,但也在本地机器上尝试过。它都会导致以下错误消息:

无法为具有 my.domain.com 权限的 SSL/TLS 安全通道建立信任关系

客户端的配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpsBinding>
                <binding name="*MyServiceBinding*" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" >
                    <security mode="Transport">
                        <transport clientCredentialType="Certificate" />
                    </security>
                </binding>
            </basicHttpsBinding>
        </bindings>
        <behaviors>
            <endpointBehaviors>
                <behavior name="endpointBehavior">
                    <clientCredentials >
                        <clientCertificate findValue="my.domain.com" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
                    </clientCredentials>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <client>
            <endpoint address="https://my.domain.com/myService.svc"
                behaviorConfiguration="endpointBehavior" binding="basicHttpsBinding"
                bindingConfiguration="myServiceBinding" contract="MyService.IMyService"
                name="MyServiceEndpoint">
                <identity>
                    <certificateReference findValue="my.domain.com" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" isChainIncluded="false" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

webservice的配置,我只提取了相关部分(据我所知):

<bindings>
    <basicHttpsBinding>
        <binding name="basicHttpsEndpointBinding">
            <security mode="Transport">
                <transport clientCredentialType="Certificate"/>
            </security>
        </binding>
    </basicHttpsBinding>
</bindings>

<serviceBehaviors>
    <behavior name="httpsBehaviour">
        <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" httpsGetBindingConfiguration="basicHttpsEndpointBinding"  />
        <serviceDebug includeExceptionDetailInFaults="true" />
        <serviceCredentials>
            <serviceCertificate findValue="my.domain.com" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
        </serviceCredentials>
    </behavior>
</serviceBehaviors>

<service behaviorConfiguration="httpsBehaviour" name="My.Service.MyService">
    <endpoint binding="basicHttpsBinding" bindingConfiguration="basicHttpsEndpointBinding" name="MyServiceEndpoint" contract="My.Service.MyService.Interfaces.IMyInterFace">
        <identity>
            <certificateReference findValue="my.domain.com" isChainIncluded="false" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
        </identity>
    </endpoint>
</service>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
    <baseAddressPrefixFilters>
        <add prefix="https://my.domain.com/" />
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>

如果需要任何额外的信息,那么我很乐意并愿意提供。如果有任何不清楚的地方,请询问,我会尽力澄清。

非常感谢任何帮助!

编辑:格式化、记录信息

【问题讨论】:

    标签: web-services security ssl iis-6 client-certificates


    【解决方案1】:

    最终我通过使用下面的stackoverflow问题解决了这个问题:

    HTTP error 403.16 - client certificate trust issue

    简而言之,微软在 windows server 2012 中更新了其安全性。这意味着,如果 Trusted Root Certification Authorities 存储中存在主题不等于 的任何证书,该服务将返回一个403.16 http异常。

    错误消息由 IIS 记录在 C:\inetpub\logs\LogFiles\W3SV*。 '*' 是您的站点在 IIS 中的 ID。

    请注意,IIS 的日志记录会定期添加到日志文件中!

    在查看日志文件后,我遇到了 403.16 异常,并遇到了上述堆栈溢出问题。

    我删除了我们添加的所有证书,这些证书是自签名的,并且颁发者和主题不匹配。这样就解决了问题。

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 2023-03-15
      • 1970-01-01
      • 2010-12-17
      • 2018-11-10
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多