带有可选客户端证书的WCF Rest Service

时间:2013-05-22 07:34:37

标签: wcf rest ssl client-certificates

是否可以拥有一个WCF Rest Web服务,该服务不包括SSL客户端证书,并且IIS SSL设置为设置为“需要SSL”并且可以“接受”客户端证书而不是“要求” “他们?

我有以下配置:

<system.serviceModel>
<services>
  <service behaviorConfiguration="RestServiceBehaviour" name="PM.WCF.Service.PmRestService">
    <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
      bindingConfiguration="StreamedRequestWebBinding" contract="PM.WCF.Service.IPmRestService"  />
  </service>
</services>

<bindings>
  <webHttpBinding>
    <binding name="StreamedRequestWebBinding"
             bypassProxyOnLocal="true"
             useDefaultWebProxy="false"
             hostNameComparisonMode="WeakWildcard"
             sendTimeout="10:15:00"
             openTimeout="10:15:00"
             receiveTimeout="10:15:00"
             maxReceivedMessageSize="2147483647"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647"
             transferMode="StreamedRequest">

      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>

<behaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="RestServiceBehaviour">
      <serviceMetadata httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我的问题是以下一行:

<transport clientCredentialType="Certificate"/>

如果我使用此设置并且IIS配置为接受但不需要客户端证书,则会收到以下错误:

  

服务'SslRequireCert'的SSL设置与IIS'SsllNegotiateCert'的SSL设置不匹配。

伤心地设置

<transport clientCredentialType="None"/>

也不起作用。我很确定浏览器/客户端确实发送了它的证书,但OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.IsAuthenticatedFalse

还有其他方法可以拥有两个IIS网站,一个配置为需要SSL和客户端证书,另一个不配置?

即使没有办法解决它。如何在Visual Studio中调试它?因为我需要SSL客户端证书的那一刻,我不能只启动Web服务。 Visual Studio尝试访问http://localhost/Foo.WCF.Service/debugattach.aspx并因缺少客户端证书而失败。

0 个答案:

没有答案
相关问题