wcf - At least one security token in the message could not be validated -
server config:
<?xml version="1.0"?> <configuration> <system.servicemodel> <behaviors> <servicebehaviors> <behavior name="servicecredentialsbehavior"> <servicecredentials> <servicecertificate findvalue="cn=cool" storename="trustedpeople" storelocation="currentuser" /> </servicecredentials> <servicemetadata httpgetenabled="true" /> </behavior> </servicebehaviors> </behaviors> <services> <service behaviorconfiguration="servicecredentialsbehavior" name="service"> <endpoint address="" binding="wshttpbinding" bindingconfiguration="messageandusername" name="securedbytransportendpoint" contract="iservice"/> </service> </services> <bindings> <wshttpbinding> <binding name="messageandusername"> <security mode="message"> <message clientcredentialtype="username"/> </security> </binding> </wshttpbinding> </bindings> <client/> </system.servicemodel> <system.web> <compilation debug="true"/> </system.web>
my client config:
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.servicemodel> <behaviors> <endpointbehaviors> <behavior name="localcertvalidation"> <clientcredentials> <servicecertificate> <authentication certificatevalidationmode="peertrust" trustedstorelocation="currentuser" /> </servicecertificate> </clientcredentials> </behavior> </endpointbehaviors> </behaviors> <bindings> <wshttpbinding> <binding name="wshttpbinding_iservice" > <security mode="message"> <message clientcredentialtype="username" /> </security> </binding> </wshttpbinding> </bindings> <client> <endpoint address="http://localhost:48097/wcfserver/service.svc" binding="wshttpbinding" bindingconfiguration="wshttpbinding_iservice" contract="servicereference1.iservice" name="wshttpbinding_iservice" behaviorconfiguration="localcertvalidation"> <identity> <dns value ="cool" /> </identity> </endpoint> </client> </system.servicemodel>
service:
public string testaccess() { return operationcontext.current.servicesecuritycontext.primaryidentity.name; }
client:
serviceclient client = new serviceclient(); client.clientcredentials.username.username = "admin"; client.clientcredentials.username.password = "123"; console.writeline(client.testaccess()); console.readline();
error:
unsecured or incorrectly secured fault received other party. see inner faultexception fault code , detail.
inner exception:
@ least 1 security token in message not validated.
how resolve exception?
i think problem user name , password. default configuration user name , password validated windows account. if want other validation must either use membership provider or custom user name password validator.
Comments
Post a Comment