在使用SSL向IIS Express中托管的WCF服务添加服务引用时遇到问题

本文关键字:服务 WCF 添加 引用 问题 遇到 SSL IIS Express | 更新日期: 2023-09-27 17:50:24

我在Visual Studio 2010的IIS Express中托管了一个普通的WCF服务。IIS Express已配置为使用SSL。

在切换到SSL之前,我没有任何问题,但现在我无法更新或添加服务引用到我的WCF服务(这只是一个正常的IIS托管svc文件)。

当我使用WCFTestClient时,我得到一个更有用的错误:

错误:无法从https://localhost:44302/Services/TrueChecksService.svc获取元数据如果这是您有权访问的Windows (R)通信基础服务,请检查您是否已在指定地址启用了元数据发布。有关启用元数据发布的帮助,请参阅MSDN文档http://go.microsoft.com/fwlink/?LinkId=65455 . ws - metadata Exchange Error URI: https://localhost:44302/Services/TrueChecksService.svc元数据包含无法解析的引用:'https://localhost:44302/Services/TrueChecksService.svc'。无法与权限"localhost:44302"建立SSL/TLS安全通道的信任关系。底层连接已关闭:无法为SSL/TLS安全通道建立信任关系。根据验证过程,远程证书无效。HTTP GET错误URI: https://localhost:44302/Services/TrueChecksService.svc下载"https://localhost:44302/Services/TrueChecksService.svc"出错。底层连接已关闭:无法为SSL/TLS安全通道建立信任关系。根据验证程序,远程证书无效。

这是我目前的配置:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBindingConfig" receiveTimeout="00:15:00"
      sendTimeout="00:15:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>    
</bindings>
<services>
  <service name="TrueChecksService" behaviorConfiguration="TrueChecksServiceBehavior">
    <endpoint binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBindingConfig"
      name="TrueChecksServiceEndpoint" contract="TrueChecksAdminSL.Web.Services.ITrueChecksService" />
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="TrueChecksServiceBehavior">
      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add port="44302" scheme="https"/>
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我是否需要编写自定义证书验证器,因为IIS Express生成自签名证书?我试图在不这样做的情况下解决问题,因为当我部署到IIS时,该站点将配置由证书颁发机构颁发的证书。

谢谢你的帮助

在使用SSL向IIS Express中托管的WCF服务添加服务引用时遇到问题

从IE中浏览URL。您将看到网站安全证书有问题的警告。按照"我需要做什么才能获得ie8-接受自签名证书"中的步骤操作。当这是成功的,并且您可以在IE中访问站点而不会收到警告时,WCFClient也可以访问它。