title: Could not establish secure channel for SSL/TLS with authority 'xxxxx.com'
body: <p>I'm trying to write a client against a customer's SOAP webservice, using VS2013 and WCF. The webservice itself is behind their firewall, so they've established a proxy that I'm trying to contact.  (The proxy seems to be implemented using MuleSoft's ESB, which may or may not be relevant.)</p>
  
  <p>I've been given an https: url, and a username/password. When I load the url into a browser, I'm prompted for the username/password, and then I see the .wsdl. The .wsdl specifies an internal url that I can't access, but I figure that's for the actual site.</p>
  
  <p>When I create a Service Reference in VS2013, using the proxy URL, I'm prompted for the username/password three times, then I get a proper client, settings in app.config, etc.</p>
  
  <p>The generated bindings in the app.config are for a basicHttpBinding with security mode Transport, and an endpoint address pointing to that inaccessible internal url.</p>
  
  <p>So, from the generated bindings, I:</p>
  
  <ol>
  <li>Replace the inaccessible internal url with the proxy url I've been given.</li>
  <li><p>Change the security mode to "TransportWithMessageCredentials"</p>
  
  <pre><code>&lt;bindings&gt;
      &lt;basicHttpBinding&gt;
          &lt;binding name="MyCustomersServiceSoapBinding"&gt;
              &lt;security mode="TransportWithMessageCredential" &gt;
                  &lt;message clientCredentialType="UserName" /&gt;
              &lt;/security&gt;
          &lt;/binding&gt;
          &lt;binding name="MyCustomersServiceSoapBinding1" /&gt;
      &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  </code></pre></li>
  <li><p>Replace the ClientCredentials with username and password:</p>
  
  <p>using (var client = new MyCustomersServiceClient())
  {
      var loginCredentials = new ClientCredentials();
      loginCredentials.UserName.UserName = "ausername";
      loginCredentials.UserName.Password = "apassword";</p>
  
  <pre><code>var defaultCredentials = client.Endpoint.Behaviors.Find&lt;ClientCredentials&gt;();
  client.Endpoint.Behaviors.Remove(defaultCredentials);
  client.Endpoint.Behaviors.Add(loginCredentials);
  
  var myData = new MyData
  {
  };
  
  
  var result = client.receiveData(myData);
  </code></pre>
  
  <p>}</p></li>
  </ol>
  
  <p>When I run it, I get an exception:</p>
  
  <blockquote>
    <p><strong><em>Could not establish secure channel for SSL/TLS with authority 'xxxxx.com'.</em></strong></p>
  </blockquote>
  
  <p>Browsing around, most of what I find suggests problems with ssl certificates, but I'm not sure that makes sense. If that were the case, I'd expect to see issues when I view the .wsdl through the browser. And I thought that by removing the default client credentials, I'd be bypassing the certificate check. And I am seeing a few posts about more obscure problems that result in this same error message.</p>
  
  <p>I've turned on SOAP message logging, but that's provided me with no information. It shows the failed outgoing message, but nothing of use.</p>
  
  <p>So I've been looking at the traffic in Fiddler. I see two messages, an HTTP message to "Tunnel to" with Result 200, and an HTTPS message to the proxy url with Result 401.</p>
  
  <p>At this point, I see two possibilities:</p>
  
  <ol>
  <li>I need to install an SSL certificate, the way the error message would suggest, or</li>
  <li>the problem is simply that I'm not providing the username/password to the service in a way that it understands, and it's rejecting my attempt to connect.</li>
  </ol>
  
  <p>I'm leaning towards the latter.  My problem? I know nothing about the system that's hosting the service. I'm passing username/password in what I thought was the usual mechanism for WCF, and it's not working.</p>
  
  <p>So, finally, the questions:</p>
  
  <ul>
  <li>Have I misled myself, and I do need to be messing about with SSL certificates?</li>
  <li>If not, what do I do in WCF to pass a username/password to an HTTPS webservice, hosted by MuleSoft 
  ESB?  (Mule EE Core Extensions/3.5.1, if that helps).</li>
  </ul>