1

IIS7でSSLを使用してWCFWebサービスをセットアップしようとしていますが、構成ファイルで少し迷っています。サーバーからクライアントへのデータを文字化けさせたい(SSLでこれで十分ですか?)クライアントは、証明書を介してサーバーに対して自身を識別する必要もあります。

次の証明書を用意しています。

  • dev.test.com -URL https://dev.test.com/TestService.svcにアクセスすると、この有効な証明書が配置されていることがわかります。
  • TestServer-サーバーを識別するダミーの証明書(本当にこれが必要ですか?または、dev.test.comを再利用できますか? server.test.comがあるかもしれませんか?)
  • TestClient-クライアント側のダミー証明書

そして、これは私の設定ファイルがどのように設定されているかです:

Web.config(サーバー):

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding"
             messageEncoding="Mtom">
      <security mode="Message">
        <transport clientCredentialType="None" />
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<services>
  <service
    name="TestService"
    behaviorConfiguration="TestServiceBehavior">
    <endpoint
      name="TestEndPoint"
      address=""
      binding="wsHttpBinding"
      bindingConfiguration="wsHttpEndpointBinding"
      bindingNamespace="http://www.example.com/"
      contract="iWebService">
      <!--<identity>
        <dns value=""/>
      </identity>-->
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding"  bindingConfiguration="" name="MexHttpsBindingEndpoint" contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="TestServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust" />
        </clientCertificate>
        <serviceCertificate findValue="TestServer" storeLocation="LocalMachine"
          storeName="My" x509FindType="FindBySubjectName" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

App.config(クライアント):

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding" bypassProxyOnLocal="false"
      transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
      allowCookies="false">
      <reliableSession ordered="true"
        enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Certificate" negotiateServiceCredential="true"
          algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="TestEndPoint" bypassProxyOnLocal="false"
      transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      messageEncoding="Mtom"
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <reliableSession ordered="true"
        enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Certificate" negotiateServiceCredential="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<client>
  <endpoint address="https://dev.test.com/TestService.svc"
    behaviorConfiguration="TestServiceBehavior"
    binding="wsHttpBinding" bindingConfiguration="wsHttpBinding"
    contract="IContractName" name="wsHttpBinding">
    <identity>
      <dns value="TestServer" />
    </identity>
  </endpoint>
  <endpoint address="https://dev.test.com/DistributionCenterService.svc"
    binding="wsHttpBinding" bindingConfiguration="TestEndPoint" contract="IContract.Name"
    name="TestEndPoint" />
</client>

<behaviors>
  <endpointBehaviors>
    <behavior name="TestServiceBehavior">
      <clientCredentials>
        <clientCertificate findValue="TestClient"
                           storeName="My"
                           storeLocation="CurrentUser"
                           x509FindType="FindBySubjectName"/>
        <serviceCertificate>
          <authentication
            certificateValidationMode="PeerOrChainTrust"
            revocationMode="NoCheck"
            trustedStoreLocation="CurrentUser"/>
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

https://dev.test.com/TestService.svcにアクセスしようとすると、次のようになります。
Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https].

とにかく、私はどの構成設定を使用すべきか本当に迷っています。

4

1 に答える 1

1

httpsを使用できるようにするには、クライアントのwsHttpBindingのセキュリティモードがTransportまたは(おそらくあなたの場合)TransportWithMessageCredentialのいずれかである必要があると思います。

于 2012-05-17T17:02:36.380 に答える