0

おそらくIEndpointBehaviorを実装することにより、実行時にbasicHttpBindingの構成で通常指定されるトランスポートセキュリティを設定する方法はありますか?

基本的にこれを取ります:

<binding name="DfsAgentService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1000000" maxBufferPoolSize="10000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                <security mode="None"/><!--Transport-->   
            </binding>

そして代わりにこれ(または何か他のもの)を使用してください:

namespace Endpoints {
    class DfsEndpoint : IEndpointBehavior{


        #region IEndpointBehavior Members

        void IEndpointBehavior.AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) {
            throw new NotImplementedException();
        }

        void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) {
            throw new NotImplementedException();
        }

        void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) {
            throw new NotImplementedException();
        }

        void IEndpointBehavior.Validate(ServiceEndpoint endpoint) {
            throw new NotImplementedException();
        }

        #endregion
    }
}

セキュリティモードを変更することはできますか?

4

1 に答える 1

0

エンドポイントの動作を介してこれを行うことはできないと思います。ビヘイビアーは、バインディング構成を十分に早く修正することはできません。

ただし、別の方法でコードで実行できます。BasicHttpBinding には、セキュリティ モードを指定できるコンストラクター オーバーロードがあります。

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

これは、サービスを開始する前に行う必要があり、ServiceHost とエンドポイントを自分で作成していると想定しています。

于 2010-11-19T15:43:52.330 に答える