title: WCF - wsHttpBinding with UserName Autentication and Message - error message "An error occurred when processing the security tokens in the message"
body: <p>I'm trying to create WCF applications with username authentication. And this error occurring. </p>
  
  <p><b>This is the service configuration:</b></p>
  
  <p>Web.config</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="Jsl.BureauInf.Services.BureauInfSVC" behaviorConfiguration="ServiceBehavior"&gt;
          &lt;endpoint address="" binding="wsHttpBinding" contract="Jsl.BureauInf.Contracts.ICliente" bindingConfiguration="ServiceBinding"/&gt;
          &lt;endpoint address="" binding="wsHttpBinding" contract="Jsl.BureauInf.Contracts.IMotorista"  bindingConfiguration="ServiceBinding"/&gt;
          &lt;endpoint address="" binding="wsHttpBinding" contract="Jsl.BureauInf.Contracts.ITransportadora" bindingConfiguration="ServiceBinding"/&gt;
          &lt;endpoint address="" binding="wsHttpBinding" contract="Jsl.BureauInf.Contracts.IVeiculo" bindingConfiguration="ServiceBinding"/&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="ServiceBinding"&gt;
            &lt;security mode="Message"&gt;
              &lt;message clientCredentialType="UserName"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="ServiceBehavior"&gt;
            &lt;serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" /&gt;
            &lt;serviceMetadata httpGetEnabled="True"/&gt;
            &lt;serviceCredentials&gt;
              &lt;serviceCertificate findValue="Uareubinf"
                    storeLocation="LocalMachine"
                    storeName="My"
                    x509FindType="FindBySubjectName" /&gt;
              &lt;userNameAuthentication userNamePasswordValidationMode="Custom"
                  customUserNamePasswordValidatorType="Jsl.BureauInf.Security.Autenticacao, Jsl.BureauInf.Security" /&gt;
            &lt;/serviceCredentials&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
    &lt;system.net&gt;
      &lt;defaultProxy useDefaultCredentials="true"/&gt;
    &lt;/system.net&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><b>Class Autentication</b></p>
  
  <pre><code>namespace Jsl.BureauInf.Security
  {
  public class Autenticacao : UserNamePasswordValidator
  {
      public override void Validate(string userName, string password)
      {
          if (userName != "yaron")
              throw new SecurityTokenException("Unknown Username or Password");
      }
  }
  }
  </code></pre>
  
  <p><b>Client</b></p>
  
  <pre><code>    BureauService.TransportadoraClient service = new BureauService.TransportadoraClient();
      service.ClientCredentials.UserName.UserName = "xxx";
      service.ClientCredentials.UserName.Password = "xxx";
      service.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
  
      BureauService.RESPOSTADTC rep = service.ConsultarTransportadora(consulta);
  </code></pre>
  
  <p>When the client makes request for service triggers the following error:</p>
  
  <p>InnerException.Message: An error occurred when processing the security tokens in the message.</p>
  
  <p>Message: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.</p>
  
  <p><b>What should I do to fix this error?</b></p>