是否可以使用 WsHttpBinding 通过基本身份验证代理? [英] Is it possible to get through a Basic authentication proxy using WsHttpBinding?

查看:18
本文介绍了是否可以使用 WsHttpBinding 通过基本身份验证代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用带有 WSHttpBinding 的基本身份验证通过身份验证代理时遇到问题.

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

BasicHttpBinding 的类似代码有效.我猜我的问题与我无法将 WSHttpBinding 的安全模式设置为 TransportCredentialOnly ..

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..

由于对 MTOM 的依赖,我无法使用 BasicHttpBinding.

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();

推荐答案

经过一番研究,我找到了答案.(我对解决方案并不完全满意,希望有另一种方法来解决这个问题)

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 不允许以明文形式发送用户名和密码,甚至不允许发送到本地身份验证代理!basicHttpBinding 没有这个问题

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).

通过在服务器上安装 SSL 证书,上述代码无需修改即可运行.服务器上的 SSL 给我带来了许多问题.

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?

这篇关于是否可以使用 WsHttpBinding 通过基本身份验证代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆