使用单个证书托管多个WCF服务

时间:2013-06-22 13:41:22

标签: wcf iis-7 certificate hosting wcf-binding

我在IIS中的“Default WebSites”下的自己的应用程序目录中分别在服务器上部署了三种不同的WCF服务。其中一项服务由我部署,另外两项服务由其他客户部署。在IIS中部署了一个服务器证书,我已经绑定了我的服务。

但是当我尝试访问我的服务表单https时,我在弹出窗口中收到此错误:

地址不匹配。 本网站提供的安全证书是针对不同网站的地址发布的。 此问题可能表示试图欺骗您或拦截您发送到服务器的任何数据。

我的服务的web.config文件如下

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<identity impersonate="false" />
</system.web>

<system.serviceModel>
<services>
  <service name="WcfApp.Service">    

    <endpoint address="customer"
              binding="basicHttpBinding"
              bindingConfiguration="secureHttpBinding"
              contract="WCFApp.ICustomerService" />        

    <endpoint address="order"
              binding="basicHttpBinding"
              bindingConfiguration="secureHttpBinding"
              contract="WcfApp.IOrderService" />

    <endpoint address="mex"
              binding="mexHttpsBinding"
              contract="IMetadataExchange" />

  </service>
 </services>

 <bindings>
  <basicHttpBinding>
    <binding name="secureHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior >
      <serviceMetadata httpsGetEnabled="True" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="21" maxConcurrentSessions="50" />         
    </behavior>
  </serviceBehaviors>
 </behaviors>
 <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>   
<directoryBrowse enabled="true" />
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>

有趣的是,当我点击以下网址时: https://myserverurl.com/applicationfolder/service.svc?wsdl

获取wsdl,它运行完美并返回wsdl描述,但原始调用无效。

为什么我收到“不匹配的地址”?是否需要添加主机基地址?如果是,在web.config中如何以及在何处准确添加它是否需要在其他两个部署的wcf服务中添加它?端口是否与证书冲突?我是wcf的新手,请帮我解决这个问题?

我正在使用.net 4.0,IIS 7.0,Windows Server 2008。

提前致谢。

1 个答案:

答案 0 :(得分:0)

错误消息 (基本上)表示您用于站点的证书与正在使用的DNS名称(从客户端的浏览器)不匹配以连接到站点。

我的猜测是你正在实施虚拟主机;即从一个IIS实例提供的具有不同DNS名称的多个服务。这不起作用...除非您为每个服务使用不同的证书,或者使用与所有服务DNS名称匹配的通配符证书。

显然,7.0之前的IIS不支持基于名称的SSL虚拟主机。 This article介绍了如何为IIS 7.0配置它。但请注意,相应证书中的名称必须匹配相应的虚拟主机名...


请注意,主机名和证书必须匹配的要求是SSL安全性的基础。它允许浏览器/用户知道它正在与预期的服务器(基于DNS名称)进行通信,而不是某些冒名顶替站点。