首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >WCF给出不安全或不正确的安全错误

WCF给出不安全或不正确的安全错误
EN

Stack Overflow用户
提问于 2009-09-27 22:02:41
回答 21查看 142.8K关注 0票数 75

我正在尝试使用远程svc web服务。我使用svcutil.exe创建了代理类,之后我将该类添加到了控制台应用程序中,但它会产生一个错误:

从另一方收到不安全的错误或不正确的安全错误。有关故障代码和详细信息,请参阅内部故障异常。

System.ServiceModel.FaultException:验证消息安全性时出错

我没有创建WCF端,它是一个远程服务。请帮帮忙。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="EloquaDataTransferService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc"
                binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService"
                contract="DataTransferService" name="EloquaDataTransferService" />
        </client>
    </system.serviceModel>
</configuration>

这是我的app.config文件。我使用obj.ServiceCredentials.UserName.UserName="xxxxxx".Password="xxxXx"consoleApp.cs文件中提供用户名和密码

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.serviceModel>
      <bindings>
         <basicHttpBinding>
            <binding name="EloquaDataTransferService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
               <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
               <security mode="TransportWithMessageCredential">
                  <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                  <message clientCredentialType="UserName" algorithmSuite="Default" />
               </security>
            </binding>
         </basicHttpBinding>
      </bindings>
      <client>
         <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc" binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService" contract="DataTransferService" name="EloquaDataTransferService" />
      </client>
   </system.serviceModel>
</configuration>
EN

回答 21

Stack Overflow用户

发布于 2010-01-09 07:23:27

这是WCF服务抛出的一个非常隐蔽的错误。问题是WCF无法验证传递给服务的消息的安全性。

这几乎总是由于服务器时间偏差造成的。远程服务器和客户端的系统时间必须(通常)在10分钟之内。如果不是,安全验证将失败。

我会调用eloqua.com,找出他们的服务器时间,并将其与您的服务器时间进行比较。

票数 135
EN

Stack Overflow用户

发布于 2011-09-02 16:11:27

虽然你的问题已经用上面的一个解决方案解决了,但为了其他人的利益,这里有另一个选择。

当将不正确的凭据传递给使用用户名消息凭据的基本终结点(SOAP1.1)时,您也会得到此异常。例如,如果您从代码中调用服务,并执行如下操作:

var service = new TestService();

service.ClientCredentials.UserName.UserName = "InvalidUser";
service.ClientCredentials.UserName.Password = "InvalidPass";

这与WSHTTP端点(SOAP1.2)不同,后者在传递无效凭据时抛出AccessDeniedException。我个人认为这里包含的信息有点误导(因为这个原因,我第一次遇到它肯定花了我几分钟的时间),但是一旦我查阅了WCF诊断跟踪日志,潜在的原因就很清楚了。

票数 26
EN

Stack Overflow用户

发布于 2009-09-27 22:35:50

显然,您的WCF安全子系统有问题。您使用的是什么绑定?什么身份验证?加密?签名?您必须跨域边界吗?

进一步观察一下,如果客户端和服务器的时钟不同步(超过五分钟),其他人就会遇到这个错误,因为一些安全模式依赖于同步的时钟。

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1484601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档