将客户端证书添加到standardEndpoint?

时间:2012-04-10 14:17:34

标签: c# wcf web-config client-certificates

我有一个REST服务,我想要客户端证书。 system.serviceModel如下所示:

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="TestService" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

我尝试将standardEndpoint修改为:

<standardEndpoint name="TestService" helpEnabled="true" automaticFormatSelectionEnabled="true">
  <security mode="Transport">
    <transport clientCredentialType="Certificate" />
  </security>
</standardEndpoint>

但这没有帮助。我缺少什么来启用客户端证书?

2 个答案:

答案 0 :(得分:2)

标准绑定不支持该语法。你必须在绑定下的webHttpBinding上定义它并且不给它命名。这样它适用于所有webHttoBinding。

<system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding>
                    <security mode="Transport">
                        <transport clientCredentialType="Certificate" />
                    </security>
                </binding>
            </webHttpBinding>
        </bindings>
        <standardEndpoints>
            <webHttpEndpoint>
                <standardEndpoint name="TestService" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
            </webHttpEndpoint>
        </standardEndpoints>
    </system.serviceModel>

答案 1 :(得分:0)

在配置中有一个DNS标签?

之类的东西
<dns value="localhost" /> 

希望这个肝脏