1

そのため、クライアントとサービスの証明書認証を設定しようとしています。最終的な目標は、クライアントが接続する証明書に基づいてデータを分割することです (つまり、証明書はより大きなシステムへの資格情報になり、データはこれらの資格情報に基づいて分割されます)。

クライアント側とサーバー側の両方で正常にセットアップできました。証明書と秘密鍵を作成し、コンピューターにインストールし、1) 証明書ベースのサービス資格情報を持ち、2) クライアントが証明書ベースの資格情報を提供せずに接続した場合に例外が発生するようにサーバーをセットアップしました。投げた。

次に、単純なクライアントを作成し、証明書の資格情報を構成に追加して、サービスで単純な操作を呼び出してみました。

クライアントが正常に接続しているように見え、証明書がサーバーによって受け入れられているように見えますが、私はこれを取得します:

セキュリティネゴシエーション例外:

「呼び出し元がサービスによって認証されませんでした。」

それは私にはかなりあいまいに思えます。wsHttpBinding を使用していることに注意してください。これは、トランスポート セキュリティのために Windows 認証にデフォルト設定されていると思われますが、これらのプロセスはすべて、デバッグ環境で実行しているため、ユーザー アカウントとして実行されています。

これが私のサーバー構成です:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MyServiceBinding">
          <security mode="Message">
            <transport clientCredentialType="None"/>
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyServiceBehavior" name="MyService">
        <endpoint binding="wsHttpBinding" bindingConfiguration="MyServiceBinding" contract="IMyContract"/>
        <endpoint binding="mexHttpBinding" address="mex" contract="IMetadataExchange">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <serviceCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

これが私のクライアント構成です。サービスで使用するのと同じ証明書をクライアントに使用していることに注意してください。

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IMyService" 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="Certificate" negotiateServiceCredential="true" algorithmSuite="Default"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:50120/UserServices.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" behaviorConfiguration="IMyService_Behavior" contract="UserServices.IUserServices" name="WSHttpBinding_IMyService">
            <identity>
                <certificate encodedValue="Some RSA stuff"/>
            </identity>
        </endpoint>
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="IMyService_Behavior">
          <clientCredentials>
            <clientCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
</system.serviceModel>

ここに何があるかについての洞察を提供してくれる人はいますか?

ありがとう、

4

1 に答える 1

0

明白なものは何も見えませんが、このリンクCodePlex: Message Security With Certificates Guideをチェックしてください。見落としているものがあるかもしれません。ガイドで気づいたことの 1 つは、サーバー構成IDブロックがコメント化されていることです。

于 2010-04-16T08:15:31.510 に答える