プログラムで BasicHtttpBinding のクロック スキューを増加させようとしています。CreateUserNameOverTransportBinding モードを使用して TransportSecurityBindingElement を使用しています。バインド要素のクロック シチューを 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>
プログラムで要素を変更できません。ここで直面する問題は、TransportSecurityBindingElement から SecureConversationSecurityTokenParameters を取得することです。以下の私のコードを見てください。
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 への変換時に null を返します。
secureConversation = security.EndpointSupportingTokenParameters.SignedEncrypted[0] as
SecureConversationSecurityTokenParameters;
WShttpBinding には多くのコード スニペットとヘルプがありますが、ストリーミングを使用しているため、それを利用することはできません。助けてください。