c# - WCF message security with username credential type -


i work on project has tcp wcf service message security mode , username credential type certificate. when client call wcf service error occurred:

exception: secure channel cannot opened because security negotiation remote endpoint has failed. may due absent or incorrectly specified endpointidentity in endpointaddress used create channel. please verify endpointidentity specified or implied endpointaddress correctly identifies remote endpoint.

inner exception: request security token has invalid or malformed elements.

how can fix it?

service web.config

<?xml version="1.0"?> <configuration>   <configsections>     <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false"/>   </configsections>   <appsettings>     <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true"/>   </appsettings>   <system.web>     <compilation debug="true" targetframework="4.7"/>     <httpruntime targetframework="4.7"/>   </system.web>   <system.servicemodel>     <client/>     <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true"/>     <bindings>       <nettcpbinding>         <binding name="tcpbinding" portsharingenabled="true" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="12:00:00" sendtimeout="00:01:00" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647">           <security mode="message">             <message clientcredentialtype="username" negotiateservicecredential ="false"/>           </security>           <readerquotas maxdepth="32" maxstringcontentlength="5242880" maxarraylength="2147483646" maxbytesperread="4096" maxnametablecharcount="5242880"/>         </binding>       </nettcpbinding>     </bindings>     <services>       <service name="testwcfservice.testservice" behaviorconfiguration="tr">         <endpoint name="tcpbinding_itestservice"           address=""           binding="nettcpbinding"           bindingconfiguration="tcpbinding"           contract="testwcfservice.interfaces.itestservice" />         <endpoint           address="mex"           binding="mextcpbinding"           contract="imetadataexchange" />         <host>           <baseaddresses>             <add baseaddress="net.tcp://localhost:9110/testservice"/>           </baseaddresses>         </host>       </service>     </services>     <behaviors>       <servicebehaviors>         <behavior name="tr">           <servicemetadata httpgetenabled="true"/>           <servicedebug includeexceptiondetailinfaults="false"/>           <servicecredentials>             <clientcertificate>               <authentication certificatevalidationmode="none"></authentication>             </clientcertificate>             <usernameauthentication usernamepasswordvalidationmode="custom" customusernamepasswordvalidatortype="testwcfservice.customusernamevalidator, testwcfservice"/>             <servicecertificate findvalue="0f7a4bff777e6886bc0d4c07043e2ecddc4a917f"                                 storelocation="localmachine"                                 storename="my"                                 x509findtype="findbythumbprint" />           </servicecredentials>         </behavior>       </servicebehaviors>     </behaviors>   </system.servicemodel>   <system.webserver>     <directorybrowse enabled="true"/>   </system.webserver>   <entityframework>     <defaultconnectionfactory type="system.data.entity.infrastructure.localdbconnectionfactory, entityframework">       <parameters>         <parameter value="v11.0"/>       </parameters>     </defaultconnectionfactory>   </entityframework> </configuration> 

client app.config

<?xml version="1.0" encoding="utf-8" ?> <configuration>     <startup>          <supportedruntime version="v4.0" sku=".netframework,version=v4.7" />     </startup>     <system.servicemodel>         <bindings>             <nettcpbinding>                 <binding name="tcpbinding_itestservice">                     <security mode="message">                         <message clientcredentialtype="username" />                     </security>                 </binding>             </nettcpbinding>         </bindings>         <client>             <endpoint address="net.tcp://localhost:9110/testservice.svc"                 binding="nettcpbinding" bindingconfiguration="tcpbinding_itestservice"                 contract="testeservicereference.itestservice" name="tcpbinding_itestservice">                 <identity>                     <certificate encodedvalue="awaaaaeaaaauaaaad3pl/3d+aia8duwhbd4uzdxkkx8gaaaaaqaaanucaaawgglrmiibuaadagecahbnr9tydajdgue0b2e5p28fma0gcsqgsib3dqebbquambaxdjambgnvbamtbvnwlvmxmb4xdte3mdgyota4mjc0n1oxdti3mdgynza4mjc0n1owedeomawga1ueaxmfu1ytuzewggeima0gcsqgsib3dqebaquaa4ibdwawggekaoibaqdwa67+lqebwmbcjc1vb9ix7hwma2ubmjux66vld2xuda9qn67polfaex7xidqkfdtbg+20gapp9asdpz2nsyaeksbnyfksacsm+awet30uitjm1itdu9u9hjgip5ct0z4jv+aq5q7wtoziqzfbfcxaxxvsxpoykocdzusltjvpf3xyhdd5x/2jh9ojxpce9raffqo/2/qu0x0rzvf2ceps6dj1bemt4h2ednemv3nyxyutbejgqsdjdiprzkeb9ohuind06rnbfhgag1gkatj0ez0r31mnayh9skjklzouvfya9o0yyv3ifiaveltpl4gwy+mp689mbfhyrrfopfdpagmbaagjjzalmbmga1udjqqmmaogccsgaqufbwmbma4ga1uddwqhawuasaaaadanbgkqhkig9w0baqufaaocaqeaugsknnfeb6ybd4abiervfll0ymqt0jplukcru1mkxywpa5i2ob83z40kymysqenl8ewvjl2d50d/5vefbwkz4ukmlpwwfkbz32vv+/cznlufnlnztvcak4r2y1nxixhpqtgvzzd4p1y/vbs2mmbzyxdcdvfwxf1//zc1l8vlt/ub4gct7eipvbxk40y/cwnfd71lt8shen3lq4ggwc2p57i6wmozfzmaje7xzbfqea74ctxwwj6w/zzyhrl5b9/dybcwap4xrit+9esdegavse5qs3ob03hujo4qpvz32/n7mbbdx1zoemvjrtzlr5tjg2cqmcioob3ln3+5necoea==" />                 </identity>             </endpoint>         </client>     </system.servicemodel> </configuration> 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -