views:

470

answers:

2

I am having a problem getting through an authenticating proxy using Basic authentication with WSHttpBinding.

Similar code for BasicHttpBinding works. I am guessing that my problem something to do with the fact that I can't set the Security mode of the WSHttpBinding to TransportCredentialOnly..

I can't use BasicHttpBinding because of a dependency on MTOM.

        binding.ProxyAddress = new Uri("http://192.168.20.231:8080");
        binding.BypassProxyOnLocal = true;
        binding.UseDefaultWebProxy = false;

        WSHttpSecurity security = binding.Security;

        //security.Mode = SecurityMode.TransportCredentialOnly; //This option only exist for BasichHttpBinding
        security.Mode = SecurityMode.Transport; // Not sure what to set here

        //security.Mode = SecurityMode.TransportWithMessageCredential;
        security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
        security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;


        var client = new SyncWcfMTOMServiceClient(binding, new EndpointAddress("http://server/service.svc"));

        client.ClientCredentials.UserName.UserName = "user";
        client.ClientCredentials.UserName.Password = "pass";
        bool running = client.IsServiceRunning();
A: 

ist of all the one thing i would like to point out here Security.Mode =Transport is used in case if your targeted service is hosted on https (ssl) which is not the case with your specified URL

security.Mode = SecurityMode.Transport; // Not sure what to set here
Usman Masood
It is not hosted on https it is a pretty standard proxy server
Philip Fourie
yep! that is what i am telling you don't use security.Mode=Transport...
Usman Masood
@Usman. What do I set it to? The problem is none of the security mode options work
Philip Fourie
A: 

After some research I found an answer to this. (I am not entirely happy with the solution and hoping there is yet another way to solve this)

wsHttpBinding doesn't allow sending a username and password in clear text, not even to a local authenticating proxy! basicHttpBinding does not have this problem

After some testing I found I can get it to work by installing a server certificate on the hosting server (not to be confused with the proxy server).

By installing the SSL certificate on the server the code above works without modification. SSL on the server creates a number of problems for me.

Any other way solution for this problem?

Philip Fourie