小编Mat*_*étu的帖子

如何修复HTTPS Silverlight应用程序上下文中的WCF maxClockSkew问题?

情况:Silverlight 4应用程序通过WCF与服务器组件通信,使用basicHttpBinding和HTTPS.

这是绑定使用的服务器端:

<basicHttpBinding>
<binding name="DefaultSecuredBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
      <readerQuotas maxDepth="50" maxArrayLength="2147483647" maxStringContentLength="2147483647" />
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName"/>
        <transport clientCredentialType="None" proxyCredentialType="None"/>
      </security>
    </binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)

请注意,我们使用TransportWithMessageCredential作为安全模式.证书已在IIS上正确安装.

应用程序在本地运行时运行顺畅

但是,我们现在有外部用户连接到我们的应用程序.他们中的一些人遇到了困难,并查看服务器日志,我们发现了这个错误:

"MessageSecurityException" 安全时间戳是陈旧的,因为其过期时间('2010-10-18T22:37:58.198Z')已过去.当前时间是'2010-10-18T22:43:18.850Z'并允许时钟偏差是'00:05:00'.

我们对网络上的主题(StackoverFlow和Google ......以及Bing)进行了常规研究,以阅读有关该主题的更多信息.我们联系了用户,以确保他们与我们的服务器的时间偏移,后来得到确认.

这篇MSDN文章的开头是:http: //msdn.microsoft.com/en-us/library/aa738468.aspx

在现有绑定上使用CustomBinding,并在自定义绑定的SecurityBindingElement上设置MaxClockSkew属性.我们实现了此解决方案,但将SymmetricSecurityBindingElement更改为TransportSecurityBindingElement,因为我们与Silverlight进行安全通信的绑定是使用HTTPS的basicHttpBinding.

Web上的一些文章(包括上面列出的这篇MSDN文章)显示了代码片段,它还将maxClockSkew属性设置为从ProtectionTokenParameters获取的引导元素.我从未成功在代码中应用此部分,因为TransportSecurityBindingElement似乎没有任何ProtectionTokenParameters.

这是我们用maxClockSkew包装绑定的代码:

protected virtual System.ServiceModel.Channels.Binding WrapClockSkew(System.ServiceModel.Channels.Binding currentBinding)
    {
        // Set the maximum difference in minutes
        int maxDifference = 300;

        // Create a custom binding based on an existing binding
        CustomBinding myCustomBinding = new CustomBinding(currentBinding);

        // Set …
Run Code Online (Sandbox Code Playgroud)

security silverlight https wcf binding

6
推荐指数
1
解决办法
4878
查看次数

WCF数据服务(OData),具有继承限制的查询?

项目:使用内部EF4 CTP5代码优先方法的WCF数据服务.

我配置了具有继承(TPH)的实体.查看有关此主题的上一个问题:

以前关于多个实体的问题 - 同一个表

映射效果很好,EF4上的单元测试确认查询运行顺利.

我的实体看起来像这样:

  • ContactBase(摘要)
  • Customer(继承自ContactBase),此实体还具有针对其他实体的多个Navigation属性
  • 资源(继承自ContactBase)

我已配置了一个鉴别器,因此Customer和Resource都映射到同一个表.同样,在Ef4的观点上,每个事情都可以正常工作(单元测试所有绿色!)

但是,当通过WCF数据服务公开这个DBContext时,我得到: - CustomerBases设置暴露(客户和资源集似乎是隐藏的,是设计吗?) - 当我在客户上查询Odata时,我收到此错误:

Navigation Properties are not supported on derived entity types. Entity Set 'ContactBases' has a instance of type 'CodeFirstNamespace.Customer', which is an derived entity type and has navigation properties. Please remove all the navigation properties from type 'CodeFirstNamespace.Customer'. 
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot)
at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri …
Run Code Online (Sandbox Code Playgroud)

inheritance entity-framework entity-framework-4 wcf-data-services odata

6
推荐指数
1
解决办法
2511
查看次数