【问题标题】:Trouble adding service reference to WCF service hosted in IIS Express with SSL使用 SSL 向托管在 IIS Express 中的 WCF 服务添加服务引用时遇到问题
【发布时间】:2011-04-18 19:48:54
【问题描述】:

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

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

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

错误:无法从https://localhost:44302/Services/TrueChecksService.svc 获取元数据如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否已在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅位于 http://go.microsoft.com/fwlink/?LinkId=65455 的 MSDN 文档。WS-元数据交换错误 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 时,该站点将配置有证书颁发机构颁发的证书。

感谢您的帮助。

【问题讨论】:

    标签: c# .net wcf iis ssl


    【解决方案1】:

    从 IE 浏览 URL。您会看到网站的安全证书有问题的警告。按照what-do-i-need-to-do-to-get-ie8-to-accept-a-self-signed-certificate 中的步骤操作。当这成功并且您可以访问该站点而不会在 IE 中收到该警告时,WCFClient 也将能够访问它。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 2011-05-17
    • 1970-01-01
    相关资源
    最近更新 更多