title: netHttpsBinding with custom UserNamePasswordValidator
body: <p>I've been trying for days to get a custom <a href="http://msdn.microsoft.com/en-us/library/system.identitymodel.selectors.usernamepasswordvalidator.aspx" rel="nofollow">UserNamePasswordValidator</a> to work with my <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.nethttpsbinding.aspx" rel="nofollow">netHttpsBinding</a> for a .Net 4.5 WCF web service.  My problem is that the validator never gets called or enforced so any credentials (or no credentials) give access.</p>
  
  <p>I'm pretty sure the configuration is correct because I can use an almost identical configuration for wsHttpBinding and it works.  Here is the web.config...</p>
  
  <pre><code>&lt;services&gt;
    &lt;service name="MyNamespace.MyService" behaviorConfiguration="serviceBehavior"&gt;
      &lt;endpoint address="" binding="wsHttpBinding" contract="MyNamespace.IMyService" /&gt;
      &lt;!-- This one doesn't authenticate 
      &lt;endpoint address="" binding="netHttpsBinding" contract="MyNamespace.IMyService" /&gt;
      --&gt;
      &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;bindings&gt;
    &lt;wsHttpBinding&gt;
      &lt;binding&gt;
        &lt;security mode="TransportWithMessageCredential"&gt;
          &lt;message clientCredentialType="UserName"/&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/wsHttpBinding&gt;
    &lt;netHttpsBinding&gt;
      &lt;binding&gt;
        &lt;security mode="TransportWithMessageCredential"&gt;
          &lt;message clientCredentialType="UserName" /&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/netHttpsBinding&gt;
  &lt;/bindings&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="serviceBehavior"&gt;
        &lt;serviceCredentials&gt;
          &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.MyValidator, MyAssembly"/&gt;
        &lt;/serviceCredentials&gt;
        &lt;serviceMetadata httpsGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p>Here is the validator if that matters...</p>
  
  <pre><code>using System.IdentityModel.Selectors;
  using System.ServiceModel;
  namespace MyNamespace
  {
      public class MyValidator : UserNamePasswordValidator
      {
          public override void Validate(string userName, string password)
          {
              if (null == userName || null == password)
                  throw new FaultException("Username or Password were not set.");
              if (!(userName == "MyUser" &amp;&amp; password == "MyPassword"))
                  throw new FaultException("Unknown Username or Incorrect Password");
          }
      }
  }
  </code></pre>
  
  <p>Does anyone know why a UserNamePasswordValidator doesn't work with netHttpsBinding?  Or what I'm doing wrong?</p>