Adding client certificates to a standardEndpoint?

纵然是瞬间 提交于 2019-12-12 03:31:20

问题


I have a REST service that I would like to require client certificates. The system.serviceModel looks as follows:

  <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>

I tried modifying the standardEndpoint to be:

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

But that did not help. What am I missing to enable client certificates?


回答1:


Standard bindings don't support that syntax. You have to define it on the webHttpBinding under bindings and give it no name. That way it applies to all webHttoBinding(s).

<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>



回答2:


got a DNS tab in the config? something like

<dns value="localhost" /> 

hope this hepls



来源:https://stackoverflow.com/questions/10090497/adding-client-certificates-to-a-standardendpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!