c# - Authenticate WCF by matching client and server certificate together -


i using c#, asp.net application wcf.

i have created client certificate ( client.pfx) , installed in machine under current user.then have created , installed server certificate ( server.pfx ) in wcf hosted machine. need authenticate client matching both client , server certificate together. if there matching, have allow access of methods inside wcf. how achieve this?

you don't have write code perform certificate authentication - can handled configuration.

from article:

http://msdn.microsoft.com/en-us/library/ff648360.aspx

there number of ways specify location of certificate. example using certificate store service:

<behaviors>   <servicebehaviors>     <behavior name="servicebehavior">        <servicemetadata httpgetenabled="true" />        <servicedebug includeexceptiondetailinfaults="false" />        <servicecredentials>            <servicecertificate findvalue="cn=tempcertserver" />        </servicecredentials>     </behavior>   </servicebehaviors> 

and 1 using certificate encoded directly in config file:

<system.servicemodel>     <behaviors>         <endpointbehaviors>             <behavior name="newbehavior">                 <clientcredentials>                     <clientcertificate findvalue="cn=tempcertclient"/>                 </clientcredentials>             </behavior>         </endpointbehaviors>     </behaviors>     ...     <client>         <endpoint address="http://<<service address>>"             behaviorconfiguration="newbehavior" binding="wshttpbinding"             bindingconfiguration="wshttpenpoint1" contract="servicereference1.iservice"             name="wshttpendpoint">             <identity>                 <certificate encodedvalue="<<encode value>>" />             </identity>         </endpoint>     </client> </system.servicemodel> 

Comments