2011-06-30 1 views
0

ウェブ設定:
パスClientCredentials.UserName

<?xml version="1.0"?> 
    <configuration> 
<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="ServiceCredentialsBehavior"> 
       <serviceCredentials> 
        <serviceCertificate findValue="cool" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/> 
       </serviceCredentials> 
       <serviceMetadata httpGetEnabled="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="ServiceCredentialsBehavior" name="Service"> 
      <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService"/> 
     </service> 
    </services> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="MessageAndUserName"> 
       <security mode="Message"> 
        <message clientCredentialType="UserName"/> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client/> 
</system.serviceModel> 
<system.web> 
    <compilation debug="true"/> 
</system.web> 

クライアントCFG:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IService" > 
       <security mode="Message"> 
        <message clientCredentialType="UserName" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:48097/WCFServer/Service.svc" 
        binding="wsHttpBinding" 
        bindingConfiguration="WSHttpBinding_IService" 
        contract="ServiceReference1.IService" 
        name="WSHttpBinding_IService"> 
      <identity> 
       <dns value ="cool" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

範囲はClientCredentials.UserName.UserNameを渡すことです/秒でパスワードure接続。 私はエラーが..です

をpluralsight自己証明書とX509証明書をした:

SOAP security negotiation with 'http://localhost:48097/WCFServer/Service.svc' for target 'http://localhost:48097/WCFServer/Service.svc' failed. See inner exception for more details.

のInnerException:

The X.509 certificate CN=cool chain building failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

どのように私はこの例外を解決することができますか? よろしく、
セルジュ。

+0

**詳細は内部例外を参照してください。** –

+0

X.509証明書CN =クールチェーンビルディングに失敗しました。使用された証明書には、検証できない信頼チェーンがあります。証明書を交換するか、certificateValidationModeを変更します。証明書チェーンは処理されましたが、信頼プロバイダによって信頼されていないルート証明書で終了しました。 – croisharp

答えて

4

デフォルトで信頼されていない自己署名証明書を使用しています。

<behaviors> 
    <endpointBehaviors> 
    <behavior name="LocalCertValidation"> 
     <clientCredentials> 
     <serviceCertificate> 
      <authentication certificateValidationMode="PeerTrust" /> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 

リファレンスbehaviorConfiguration="LocalCertValidation"して、クライアントでのエンドポイント構成から、この動作:あなたはそれが証明書を信頼する必要があり、クライアントアプリケーションを伝える必要があります。これを機能させるには、現在のユーザーの証明書ストアに公開証明書をインストールする必要があります。検証モードをNoneに設定することもでき、証明書はまったく検証されませんが、開発環境でのみ使用する必要があります。

+0

http://img221.imageshack.us/img221/4124/certid.png 私はそれを追加しました(私は思う)が、例外は私がしなかったと言います。 – croisharp

+0

メッセージ内の少なくとも1つのセキュリティトークンを検証できませんでした。 私は現在のユーザーストアに証明書を入れましたが、今私はエラーを受け取ります: メッセージの少なくとも1つのセキュリティトークンを検証することができませんでした。 – croisharp