简体   繁体   English

使用TransportWithMessageCredential安全模式在wsHttpBinding中配置MaxClockSkew

[英]Configure MaxClockSkew in wsHttpBinding with TransportWithMessageCredential Security Mode

I have the following configuration for my service that is working fine. 我的服务具有以下配置,可以正常运行。 The problem appears when i need to change the value of MaxClockSkew in wsHttpBinding with TransportWithMessageCredential security mode. 当我需要使用TransportWithMessageCredential安全模式在wsHttpBinding中更改MaxClockSkew的值时,会出现问题。

How can I change the MaxClockSkew value in this configuration? 如何在此配置中更改MaxClockSkew值?

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="HttpsService_wsHttpBinding" closeTimeout="01:10:00"
          openTimeout="01:10:00" receiveTimeout="Infinite" sendTimeout="Infinite"
          maxBufferPoolSize="999999999" maxReceivedMessageSize="99999999">
          <readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
            maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
          <reliableSession inactivityTimeout="Infinite" enabled="true" />
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceApp.Service1">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpsService_wsHttpBinding"
          name="wsHttpEndPoint" contract="CommonTypes.IService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="CommonTypes.CustomValidator, CommonTypes" />
          </serviceCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483646" />
          <bufferedReceive maxPendingMessagesPerChannel="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <diagnostics wmiProviderEnabled="true">
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="true"
           maxMessagesToLog="3000"
       />
    </diagnostics>
  </system.serviceModel>

Based on the information in this post , it appears you can't change the maxClockSkew property on a standard (ie, WCF-provided) binding, you need to use a custom binding. 基于这一信息 ,它似乎无法改变maxClockSkew上一个标准的属性(即,WCF提供)绑定,您需要使用自定义绑定。 Something like this: 像这样:

<system.serviceModel>
  <bindings>
    <customBinding>
      <binding name="HttpsService_wsHttpBinding" 
               closeTimeout="01:10:00"
               openTimeout="01:10:00" 
               receiveTimeout="Infinite" 
               sendTimeout="Infinite">
        <reliableSession inactivityTimeout="Infinite" 
                         enabled="true" />
        <security authenticationMode="SecureConversation">
          <secureConversationBootstrap authenticationMode="UserNameOverTransport" />
          <localServiceSettings maxClockSkew="00:30:00" />
        </security>
        <textMessageEncoding messageVersion="soap12">
          <readerQuotas maxDepth="999999999" 
                        maxStringContentLength="999999999"
                        maxArrayLength="999999999" 
                        maxBytesPerRead="999999999"
                        maxNameTableCharCount="999999999" />
        </textMessageEncoding> 
        <httpsTransport maxBufferPoolSize="999999999"
                        maxReceivedMessageSize="99999999" />
      </binding>
    <customBinding>
  </bindings>
</system.serviceModel>

Note that the clock skew is set in the <security> section with the <localServiceSettings> element's attribute maxClockSkew (in this example, 30 minutes). 请注意,时钟偏斜是在<security>部分中使用<localServiceSettings>元素的属性maxClockSkew (在本示例中为30分钟)。 Custom bindings can be a little intimidating and/or confusing at first, but careful examination of the above example and using MSDN will be helpful. 最初,自定义绑定可能会有些吓人和/或令人困惑,但是仔细检查以上示例并使用MSDN会有所帮助。

CustomBindings is a good place to start, and note that the article indicates a specific order for the elements. CustomBindings是一个很好的起点,请注意,本文指出了元素的特定顺序。

For an overview of the config section elements and attributes, you can look here: <customBinding> . 有关config节的元素和属性的概述,可以在这里查看: <customBinding>

You will also need to set the maxClockSkew property on the client's custom binding to the same value as the service, I believe. 我相信,您还需要将客户端的自定义绑定上的maxClockSkew属性设置为与服务相同的值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF安全模式TransportWithMessageCredential - WCF Security Mode TransportWithMessageCredential WCF安全性:TransportWithMessageCredential和消息安全模式之间的区别 - WCF Security: Difference between TransportWithMessageCredential and Message Security Mode 具有wsHttpBinding,ssl和TransportWithMessageCredential的WCF服务 - WCF Service with wsHttpBinding, ssl and TransportWithMessageCredential WSHttpBinding TransportWithMessageCredential SecurityMode改变请求 - WSHttpBinding TransportWithMessageCredential SecurityMode alters request WCF安全模式是使用UserName的TransportWithMessageCredential,在哪里验证? - WCF security mode is TransportWithMessageCredential using UserName, where to validate? 如何使SoapUI与ws安全模式“ TransportWithMessageCredential”一起使用 - How to get SoapUI to work with ws-security mode 'TransportWithMessageCredential' 使用TransportWithMessageCredential安全模式的basicHttpBinding的等效自定义WCF绑定 - Equivalent custom WCF binding for basicHttpBinding with TransportWithMessageCredential security mode 如何使用端点的 TransportWithMessageCredential 安全模式对 wsdl 进行身份验证? - How to authenticate wsdl get with TransportWithMessageCredential security mode for the endpoint? 具有安全模式TransportWithMessageCredential的pollingDuplexHttpBinding。 来自服务器的响应未到达客户端 - pollingDuplexHttpBinding with security mode TransportWithMessageCredential. response from server don't come to client Contract需要Session,但是绑定&#39;WSHttpBinding&#39;不支持它。 带有TransportWithMessageCredential的404 - Contract requires Session, but Binding 'WSHttpBinding' doesn't support it; 404 with TransportWithMessageCredential
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM