【问题标题】:WCF certificate problem - how do I switch off security for testing purposes?WCF 证书问题 - 如何关闭安全性以进行测试?
【发布时间】:2010-09-23 16:46:05
【问题描述】:

尝试连接到 WCF Web 服务时出现以下错误:

WCF web query ... Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: The caller was not authenticated by the service. ---> System.ServiceModel.FaultException: The request for security token could not be satisfied because authentication failed. at System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(Message message, EndpointAddress target) at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingM essageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)

我已经用 C# 编写了 WCF 客户端和服务器应用程序。客户端在本地运行时可以很好地与服务器通信,但是当我对复制到远程 Amazon EC2 云计算机的远程服务器进行相同的调用时出现证书请求错误。

如何在 WCF 中暂时关闭证书请求,以便查看一切是否正常?

【问题讨论】:

    标签: wcf-security


    【解决方案1】:

    知道了!关掉了安全。我现在可以与远程 WCF 服务通信,一切正常。

    关键是运行 WCF 配置工具将传输层更改为基本 HTTP 绑定,并确保默认关闭安全性。步骤如下。

    1. 右键单击 App.Config 运行“编辑 WCF 配置”。
    2. 创建一个没有安全性的新绑定。在“绑定”下选择“新绑定配置”。我选择了“basicHTTPbinding”,默认情况下没有安全性。我将此绑定配置文件命名为“nosecurity”。
    3. 将端点配置为使用此“nosecurity”绑定。在传输层(不是 mex - 这是用于服务发现)的“服务端点”下,选择“basicHTTPbinding”作为“绑定”,在“绑定配置”下,选择“nosecurity”配置文件。
    4. 现在一切正常,没有证书错误。

    这里是完整的 App.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="nosecurity" />
                </basicHttpBinding>
            </bindings>
            <services>
                <service behaviorConfiguration="PhiFeedServiceBehavior" name="NeuralFutures.Datafeed.PhiFeed">
                    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="nosecurity"
                        contract="NF.Datafeed.IPhiFeed" />
                    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                    <host>
                        <baseAddresses>
                            <add baseAddress="http://localhost:31415/PhiFeed" />
                        </baseAddresses>
                    </host>
                </service>
            </services>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="PhiFeedServiceBehavior">
                        <serviceMetadata httpGetEnabled="true"/>
                        <serviceDebug includeExceptionDetailInFaults="False"/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
        </system.serviceModel>
    </configuration>  
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-21
    • 2012-01-02
    • 1970-01-01
    相关资源
    最近更新 更多