Изменение перекоса часов для BasicHttpBinding не работает
Я пытаюсь увеличить наклон часов на BasicHtttpBinding программно. Я использую TransportSecurityBindingElement, используя режим CreateUserNameOverTransportBinding. Я могу изменить время тушения элемента привязки на 15 минут (привязка на стороне клиента печатается в файл, как показано ниже). Но перекос элемента начальной загрузки не изменяется.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.serviceModel>
<bindings>
<customBinding>
<binding name="BasicHttpBinding">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport"
requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="true"
keyEntropyMode="CombinedEntropy" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings cacheCookies="true" detectReplays="false"
replayCacheSize="900000" maxClockSkew="00:15:00" maxCookieCachingTime="Infinite"
replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true"
timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
<localServiceSettings detectReplays="false" issuedCookieLifetime="10:00:00"
maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:15:00"
negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
reconnectTransportOnFailure="true" maxPendingSessions="128"
maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
<secureConversationBootstrap />
</security>
<mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap11" maxBufferSize="10485760" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</mtomMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="10485760" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="10485760" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="StreamedRequest" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>
Я не могу изменить Elemet программно. Сложность, с которой я здесь сталкиваюсь, заключается в получении SecureConversationSecurityTokenParameters из TransportSecurityBindingElement. Пожалуйста, смотрите мой код ниже.
public static Binding CreateCustomHttpSecuredStreamingUploadBinding(TimeSpan clockSkew)
{
CustomBinding myCustomBinding = new CustomBinding(GetHttpSecuredStreamingUploadBinding());
TransportSecurityBindingElement security = myCustomBinding.Elements.Find<TransportSecurityBindingElement>();
security.LocalClientSettings.MaxClockSkew = clockSkew;
security.LocalServiceSettings.MaxClockSkew = clockSkew;
SecureConversationSecurityTokenParameters secureConversation;
secureConversation = security.EndpointSupportingTokenParameters.SignedEncrypted[0] as SecureConversationSecurityTokenParameters;
if (secureConversation != null)
{
SecurityBindingElement bootstrap = secureConversation.BootstrapSecurityBindingElement;
// Set the MaxClockSkew on the bootstrap element.
bootstrap.LocalClientSettings.MaxClockSkew = clockSkew;
bootstrap.LocalServiceSettings.MaxClockSkew = clockSkew;
}
return myCustomBinding;
}
private static BasicHttpBinding GetHttpSecuredStreamingUploadBinding()
{
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.MessageEncoding = WSMessageEncoding.Mtom;
basicHttpBinding.TransferMode = TransferMode.StreamedRequest;
basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
int MaxBufferSize = ConfigManager.GetInstance().MaxBufferSize(TConstants.HttpSecuredStreamingUpload, EndpointType.Client);
basicHttpBinding.MaxBufferSize = MaxBufferSize;
long maxReceivedMessageSize = ConfigManager.GetInstance().MaxReceivedMsgSize(TConstants.HttpSecuredStreamingUpload, EndpointType.Client);
basicHttpBinding.MaxReceivedMessageSize = maxReceivedMessageSize;
TdTimer timer = GetTimeOut(TConstants.HttpSecuredStreamingUpload, TConstants.SendTimeout);
if (timer.isSet)
basicHttpBinding.SendTimeout = timer.TimeOut;
timer = GetTimeOut(TriadTransportConstants.HttpSecuredStreamingUpload, TConstants.ReceiveTimeout);
if (timer.isSet)
basicHttpBinding.ReceiveTimeout = timer.TimeOut;
basicHttpBinding.ReaderQuotas = SetXmlDictionaryReaderQuotas(TConstants.HttpSecuredStreamingUpload);
return basicHttpBinding;
}
EndpointSupportingTokenParameters имеет элемент SignedEncrypted[0], но Endorsing[0] пуст. поэтому я использую код ниже, но он возвращает ноль при преобразовании в SecureConversationSecurityTokenParameters.
secureConversation = security.EndpointSupportingTokenParameters.SignedEncrypted[0] as
SecureConversationSecurityTokenParameters;
Есть много фрагментов кода и справки для WShttpBinding, но я не могу пойти на это, поскольку я использую потоковую передачу. Пожалуйста помоги.