2011-08-10 20 views
0

カスタムユーザー名とパスワード認証を使用するサービス証明書を作成する必要がありますか?カスタムのユーザー名とパスワードでWCFサービスを認証します。WCF認証:カスタムユーザー名とパスワード検証ツールasp.net

次のように私のサービスのweb.configファイルは次のとおりです。

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding>`enter code here` 
      <binding name="NewBinding0"> 
       <security mode="Message"> 
        <transport clientCredentialType="Basic" /> 
        <message clientCredentialType="UserName" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="WcfTest.Service1Behavior" name="WcfTest.TestService"> 
      <endpoint address="" binding="wsHttpBinding" contract="WcfTest.ITestService" /> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name="NewBehavior" /> 
     </endpointBehaviors> 
     <serviceBehaviors> 
      <behavior name="WcfTest.Service1Behavior"> 
       <serviceMetadata httpGetEnabled="false" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
       <serviceCredentials> 
        <!-- Use our own custom validation --> 
        <userNameAuthentication userNamePasswordValidationMode="Custom" 
        customUserNamePasswordValidatorType="MyValidator,WcfTest"/> 
       </serviceCredentials> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

とクライアントのWeb.configは次のとおりです。

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_ITestService" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" 
        sendTimeout="00:01:00" bypassProxyOnLocal="false" 
        transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" 
        useDefaultWebProxy="true" allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" 
           maxArrayLength="16384" maxBytesPerRead="4096" 
           maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
           enabled="false" /> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
           realm="" /> 
        <message clientCredentialType="UserName" 
          negotiateServiceCredential="true" 
          algorithmSuite="Default" 
          establishSecurityContext="true" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:2374/Service1.svc" binding="wsHttpBinding" 
        bindingConfiguration="WSHttpBinding_ITestService" 
        contract="ServiceReference1.ITestService" 
        name="WSHttpBinding_ITestService"> 
      <identity> 
       <userPrincipalName value="NYSA31\abc" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

しかし、私は、サービスへのアクセス、次のエラーを取得しています。

enter image description here

+0

サービスとクライアント間のセキュリティ設定が一致しません。サービスがメッセージセキュリティを指定していて、トランスポートがBasic ClientCredentialTypeに設定され、メッセージがUserName ClientCredentialTypeに設定されていて、クライアントがメッセージセキュリティをWindows ClientCredentialTypeに設定されたトランスポートで使用しています。それが問題なのかどうかはわかりませんが、その領域を調べたいと思うかもしれません。 – Tim

+0

@Tim:あなたの返事をありがとう。私のサービスで認証タイプとしてユーザ名を使用していますが、私はデフォルトで認証サービスを参照するように設定されています。クライアントweb.configに修正を加えましたが、同じ問題が発生しています。 –

+0

モードが 'Message'に設定されているので、' Transport'の 'ClientCreadentialType'に何が設定されているかは関係ありません。 –

答えて

1

WsHttpBindingサービス証明書を要求しています。 WCF 4(および特別なKBを持つ古いバージョン)では、証明書なしでUserNameとパスワードで認証された公開サービスが許可されますが、本当に必要ですか?これは、パケットをキャプチャする誰もが盗まれた資格情報で認証できるため、ユーザー名とパスワードはセキュリティなしのワイヤーでプレーンテキストに入れられることを意味します。

証明書なしでユーザー名パスワードを使用するには、custom bindingが必要です。またはClearUserNameBindingを使用できます。

関連する問題