質問

非常に単純なWCFサービスを公開しています。サービスを作成し、サーバーにセットアップするのに手間がかかりません。問題は、プライベートネットワーク内からサービスを使用できることですが、ネットワーク外部からサービスを使用しようとすると、次のエラーがスローされます。

  

セキュリティサポートプロバイダーインターフェイス(SSPI)ネゴシエーションに失敗しました。

少し調査したところ、WCFはデフォルトでWindows認証を使用しているようです。認証を使用しないように変更したいのですが、どのようにすればよいかよくわかりません。これが私の設定の外観です。

<system.serviceModel>
    <services>
        <service behaviorConfiguration="XX.ZZ.WebService.MyServiceBehavior"
         name="XX.ZZ.WebService.MyService">
            <endpoint  address="" binding="wsHttpBinding" contract="XX.ZZ.WebService.IMyService">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="XX.ZZ.WebService.MyServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

いくつかのポインタ、または正しい方向へのナッジをお願いします。

役に立ちましたか?

解決

まあ、あなたのサービスはwsHttpBindingを使用します。これは、デフォルトではWindowsユーザーの資格情報を必要とします-外部ユーザーには明らかに持っていません。既定でWindows資格情報を使用するのはWCF自体ではなく(指定どおり)、実際にはこの特定のバインディング(wsHttpBinding)です。デフォルトでは他の設定が使用される場合があります。

いくつかの選択肢があります:

  • セキュリティをまったく使用しないように、または発信者が提供する必要があるユーザー名/パスワードセキュリティを使用するように、wsHttpBinding(かなり<!> quot; heavy-weight <!> quot;)を構成します
  • 代わりにセキュリティなしでbasicHttpBindingを使用します(基本的にASMXモデルです)

wsHttpBindingからセキュリティを完全にオフにするには、設定にこれを含めます。

<bindings>
  <wsHttpBinding>
    <binding name="NoSecurity">
      <security mode="None" />
    </binding>
  </wsHttpBinding>
</bindings>

次に、そのバインド構成を使用するようにエンドポイントを構成します:

<system.serviceModel>
    <services>
        <service name="XX.ZZ.WebService.MyService"
                 behaviorConfiguration="XX.ZZ.WebService.MyServiceBehavior">
           <endpoint address="" 
                     binding="wsHttpBinding" 
                     bindingConfiguration="NoSecurity" 
                     contract="XX.ZZ.WebService.IMyService">
            </endpoint>
            <endpoint address="mex" 
                      binding="mexHttpBinding" 
                      contract="IMetadataExchange" />
        </service>
    </services>

必要に応じて、<basicHttpBinding>の代わりに<wsHttpBinding>を使用しても同じことができます(wsHttpBindingとbasicHttpBindingを使用しても、セキュリティやwsHttpBindingが提供するその他のすべての高度な機能をオフにするとメリットはありません)。

非常に優れたブログ投稿シリーズでは、WCFセキュリティの基本を5つの異なる典型的なシナリオの観点から説明しています。

マーク

他のヒント

これにより、認証なしでトランスポートレベルのセキュリティが提供されます。

<configuration>  <system.serviceModel>
    <services>
      <service 
          name="Microsoft.ServiceModel.Samples.CalculatorService"
          behaviorConfiguration="CalculatorServiceBehavior">
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="Binding1" 
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding1">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>  </system.serviceModel>
</configuration>

他のシナリオについては、 Microsoft WCFサンプル

WCFは、設定に関しては非常に苦痛です。 WCFSecurity をご覧ください。さまざまな構成環境に適した実用的なサンプルが提供されています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top