wcf ssl客户端在其他电脑上

时间:2012-04-23 09:41:36

标签: c# wcf

我在服务器PC上的WCF中构建了一个Web服务。我已经建立了一个https端点并配置了一些本地证书。现在在网络上,我正在尝试创建一个C#控制台客户端来测试服务。但我收到此错误: 未处理的异常:System.ServiceModel.Security.SecurityNegotiationException: 呼叫者未通过该服务进行身份验证。 ---> System.ServiceModel.FaultE xception:因为authenti无法满足安全令牌的请求 阳离子失败。(以及更多)..

这里是我要连接到的端点的代码:

http://pastebin.com/GGe6YaTb

这将是我的客户:

    

    <bindings>
        <wsHttpBinding>
            <binding name="WebDataServiceHttpBinding" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://anlocalip:9651/WebDataService" binding="wsHttpBinding"
            bindingConfiguration="WebDataServiceHttpBinding" contract="wcf1.IWebDataService"
            name="WebDataServiceHttpBinding">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我无法摆脱这个错误,有人可以帮助我吗?

2 个答案:

答案 0 :(得分:0)

您可能需要在客户的单元中安装/导入证书。

  

How can I install a certificate into the local machine store programmatically using c#?
stackoverflow.com

     

我有通过MakeCert生成的证书。我想使用PeerTrust将此证书用于WCF消息安全性。如何使用c#或.NET以编程方式将证书安装到“可信人”本地计算机证书存储区?


  

Install certificates in to the Windows Local user certificate store in C#
stackoverflow.com

     

我正在编写一个Windows服务,需要证书存储区中的多个证书才能连接到第三方Web服务...


使用证书保护服务

  

How to: Secure a Service with an X.509 Certificate
msdn.microsoft.com

     

使用X.509证书保护服务是Windows Communication Foundation(WCF)中大多数绑定使用的基本技术。本主题介绍使用X.509证书配置自托管服务的步骤。

答案 1 :(得分:0)

尝试在打开代理之前设置模拟级别:

serviceProxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
serviceProxy.Open();
相关问题