Wcf 服务抛出异常:无法为具有权限的 SSL/TLS 安全通道建立信任关系

Wcf service throws exception: Could not establish trust relationship for the SSL/TLS secure channel with authority

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

情况如下:

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

网站运行在专用应用程序池中,有专用用户

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

在 pfx 证书上,我在 'manage private key' 选项中授予专用用户读取权限。在调试时我还授予以下帐户读取权限:

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

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

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

Could not establish trust relationship for the SSL/TLS secure channel with authority my.domain.com

客户端配置:

<?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>

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

非常感谢任何帮助!

编辑:格式化、日志信息

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

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

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

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

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

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