0

私はサービスクラスを持っています:

namespace TestService
{
    public class Service:IService 
    {
        #region IService Members

        public string TestCall()
        {
            return "You just called a WCF webservice On SSL(Transport Layer Security)";
        }

        #endregion
    }
}

および構成サービス:

<configuration>
    <system.serviceModel>
        <services>
            <service behaviorConfiguration="returnFaults" name="TestService.Service">
                <endpoint binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="TestService.IService"/>
                <endpoint address="mex" binding="mexHttpsBinding" name="MetadataBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="returnFaults">
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                    <serviceMetadata httpsGetEnabled="true"/>
                    <serviceTimeouts/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <wsHttpBinding>
                <binding name="TransportSecurity">
                    <security mode="Transport">
                        <transport clientCredentialType="None"/>
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <diagnostics>
            <messageLogging logEntireMessage="true" maxMessagesToLog="300" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"/>
        </diagnostics>
    </system.serviceModel>
</configuration>

IISにサービスを設定し、https: "https://localhost/service.svc"およびhttp: "http://localhost/service.svc"でサービスのhttp、httpsを設定します。httpsを設定すると、証明書を設定しました。 WCFServer」。アドレス「https://localhost/service.svc」でサービスにアクセスできます。アドレス「https://localhost/service.svc」にサービス参照を追加し、サービスを呼び出します。

   ServiceReference1.ServiceClient proxy = new ServiceReference1.ServiceClient();
            proxy.TestCall();

エラーを返します:

検証手順に従って、リモート証明書が無効です。

この構成クライアント:

<configuration>


  <system.web>
    <compilation debug="true" targetFramework="4.0" />


  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IService">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://thanguk-pc/service.svc" binding="wsHttpBinding" behaviorConfiguration="firstSsl"
        bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference1.IService"
        name="WSHttpBinding_IService" >
        <identity>
          <dns value="WcfServer" />
        </identity>
      </endpoint>
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="firstSsl">
          <clientCredentials>
            <serviceCertificate>
              <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

クライアントがサービスを使用するときの問題は何ですか?ありがとう

4

1 に答える 1

1

WCFの設定は私には良さそうです。それで、私はあなたの証明書、証明書のインストール、およびホスト名に目を向け始めます(@flemが指摘したように)。誰が証明書を発行したのですか?自己署名のように聞こえます。自己署名証明書は、SSL ハンドシェーク中にクライアントで信頼されません。サーバー上でnetmonを実行し (TLS のフィルターをオンにする)、SSL ハンドシェイクを確認できます。これにより、障害が発生している場所についての洞察が得られる場合があります。

ヒントの 1 つは、サービスが機能するためには、クライアントから https 経由でメタデータ (.svc) をブラウザ証明書エラーなしで参照できる必要があることです (つまり、クロムの緑色のロックなど)。ブラウザーが緑色になった場合、通常、証明書は正しくインストールされ、構成されています。それ以外の場合、WCF はそれも拒否します (ただし、続行するオプションは提供されません)。

于 2012-07-18T08:38:33.440 に答える