9

I would like to make a WCF https-connection between a .NET core application and a full .NET webservice (Hosted in IIS), with Basic authentication.

On the .NET Core side I have a ChannelFactory set up like this:

var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

factory = new ChannelFactory<T>(binding, new EndpointAddress(endpointAddress));
factory.Credentials.UserName.UserName = "abc";
factory.Credentials.UserName.Password = "xyz";

On the webservice I have an endpoint using a binding configured like this:

<basicHttpBinding>
    <binding name="BasicHttpBinding" maxReceivedMessageSize="10485760">
      <security mode="Transport">
        <transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/>
      </security>
    </binding>
  </basicHttpBinding>

But at runtime I get this error message:

System.ServiceModel.Security.MessageSecurityException: 'The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="localhost"'.'

I was expecting both sides to say authentication scheme 'Basic' and to connect without any problems. I don't know where the realm comes from, but I can't get rid of it. I think this is causing the problem.

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
PeterVD
  • 91
  • 1
  • 4

1 Answers1

0

You already set credential type basic, then you should use HTTPS , https://localhost/....

Mucahid Uslu
  • 367
  • 3
  • 11