<komunikat> o usłudze <basicHttpBinding>

Definiuje ustawienia zabezpieczeń na poziomie komunikatów podstawowegoHttpBinding<>.

<Konfiguracji>
  <System.servicemodel>
    <Powiązania>
      <basicHttpBinding>
        <Wiązania>
          <Zabezpieczeń>
            <Komunikat>

Składnia

<message algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15"
         clientCredentialType="UserName/Certificate" />

Atrybuty i elementy

W poniższych sekcjach opisano atrybuty, elementy podrzędne i elementy nadrzędne

Atrybuty

Atrybut Opis
algorithmSuite Ustawia algorytmy szyfrowania komunikatów i zawijania klucza. Ten atrybut jest typu SecurityAlgorithmSuite, który określa algorytmy i rozmiary kluczy. Te algorytmy są mapowe na określone w specyfikacji WS-SecurityPolicy (SecurityPolicy).

Wartość domyślna to Basic256.
Clientcredentialtype Określa typ poświadczeń do użycia podczas uwierzytelniania klienta przy użyciu zabezpieczeń opartych na komunikatach. Wartość domyślna to UserName.

clientCredentialType, atrybut

Wartość Opis
Nazwa użytkownika — Wymaga uwierzytelnienia klienta na serwerze przy użyciu poświadczeń UserName. To poświadczenie należy określić przy użyciu <elementu clientCredentials>.
— WCF nie obsługuje wysyłania skrótu hasła lub wyprowadzania kluczy przy użyciu haseł i używania takich kluczy do zabezpieczeń komunikatów. W związku z tym program WCF wymusza zabezpieczenie transportu podczas korzystania z poświadczeń UserName. W przypadku programu basicHttpBindingwymaga to skonfigurowania kanału SSL.
Certyfikat Wymaga uwierzytelnienia klienta na serwerze przy użyciu certyfikatu. W tym przypadku należy określić poświadczenia klienta przy użyciu <elementu clientCredentials> i <clientCertificate>. Ponadto w przypadku korzystania z trybu zabezpieczeń komunikatów klient musi być aprowizowany przy użyciu certyfikatu usługi. Poświadczenie usługi w tym przypadku należy określić przy użyciu ClientCredentials klasy lub ClientCredentials elementu zachowania i określić certyfikat usługi przy użyciu <elementu serviceCertificate>.

Elementy podrzędne

Brak

Elementy nadrzędne

Element Opis
<Zabezpieczeń> Definiuje możliwości zabezpieczeń dla< elementu basicHttpBinding>.

Przykład

W tym przykładzie pokazano, jak zaimplementować aplikację korzystającą z podstawowych UsługHttpBinding i zabezpieczeń komunikatów. W poniższym przykładzie konfiguracji usługi definicja punktu końcowego określa podstawową konfiguracjęHttpBinding i odwołuje się do konfiguracji powiązania o nazwie Binding1. Certyfikat używany przez usługę do uwierzytelniania się na kliencie jest ustawiany w behaviors sekcji pliku konfiguracji w obszarze serviceCredentials elementu . Tryb weryfikacji stosowany do certyfikatu używanego przez klienta do uwierzytelniania się w usłudze jest również ustawiany w sekcji w behaviors obszarze clientCertificate elementu .

Te same szczegóły powiązania i zabezpieczeń są określone w pliku konfiguracji klienta.

<system.serviceModel>
  <services>
    <service name="Microsoft.ServiceModel.Samples.CalculatorService"
             behaviorConfiguration="CalculatorServiceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8000/ServiceModelSamples/service" />
        </baseAddresses>
      </host>
      <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/ServiceModelSamples/service -->
      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="Binding1"
                contract="Microsoft.ServiceModel.Samples.ICalculator" />
      <!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex -->
      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />
    </service>
  </services>
  <bindings>
    <basicHttpBinding>
    <!-- This configuration defines the SecurityMode as Message and
         the clientCredentialType as Certificate. -->
      <binding name="Binding1">
        <security mode = "Message">
          <message clientCredentialType="Certificate" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
  <behaviors>
    <serviceBehaviors>
      <behavior name="CalculatorServiceBehavior">
        <serviceMetadata httpGetEnabled="True" />
        <serviceDebug includeExceptionDetailInFaults="False" />
        <!-- The serviceCredentials behavior allows one to define a service certificate.
             A service certificate is used by a client to authenticate the service and provide message protection.
             This configuration references the "localhost" certificate installed during the setup instructions. -->
        <serviceCredentials>
          <serviceCertificate findValue="localhost"
                              storeLocation="LocalMachine"
                              storeName="My"
                              x509FindType="FindBySubjectName" />
          <clientCertificate>
            <!-- Setting the certificateValidationMode to PeerOrChainTrust means that if the certificate
               is in the user's Trusted People store, then it will be trusted without performing a
               validation of the certificate's issuer chain. This setting is used here for convenience so that the
               sample can be run without having to have certificates issued by a certification authority (CA).
               This setting is less secure than the default, ChainTrust. The security implications of this
               setting should be carefully considered before using PeerOrChainTrust in production code. -->
            <authentication certificateValidationMode="PeerOrChainTrust" />
          </clientCertificate>
        </serviceCredentials>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

Zobacz też