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.