Condividi tramite


<message> di <basicHttpBinding>

Definisce le impostazioni di protezione a livello di messaggio dell'<basicHttpBinding>.

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <associazione>
        <security> di <basicHttpBinding>
          <message> di <basicHttpBinding>

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

Attributi ed elementi

Attributi

Attributo Descrizione

algorithmSuite

Imposta la crittografia dei messaggi e gli algoritmi di incapsulamento della chiave. Questo attributo è di tipo SecurityAlgorithmSuite, che specifica gli algoritmi e le dimensioni della chiave. Questi algoritmi sono associati a quelli specificati nelle specifiche del linguaggio dei criteri di protezione (WS-SecurityPolicy).

Il valore predefinito è Basic286.

clientCredentialType

Specifica il tipo di credenziale da utilizzare se l'autenticazione client viene eseguita utilizzando la protezione basata sul messaggio. Il valore predefinito è UserName.

Elementi figlio

None

Elementi padre

Elemento Descrizione

<security> di <basicHttpBinding>

Definisce le funzionalità di protezione dell'<basicHttpBinding>.

Esempio

In questo esempio viene dimostrato come implementare un'applicazione che utilizza basicHttpBinding e la protezione del messaggio. Nel seguente esempio di configurazione di un servizio, la definizione dell'endpoint specifica basicHttpBinding e fa riferimento a una configurazione di associazione denominata Binding1. Il certificato utilizzato dal servizio per l'autenticazione con il client è impostato nella sezione behaviors del file di configurazione sotto l'elemento serviceCredentials. Anche la modalità di convalida applicata al certificato utilizzato dal servizio per l'autenticazione con il client è impostata nella sezione behaviors del file di configurazione sotto l'elemento clientCertificate.

Gli stessi dettagli sull'associazione e la protezione sono specificati nel file di configurazione del client.

<system.serviceModel>
    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:8000/ServiceModelSamples/service"/>
          </baseAddresses>
        </host>
        <!-- this endpoint is exposed at the base address provided by host: https://localhost:8000/ServiceModelSamples/service  -->
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="Binding1" 
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <!-- the mex endpoint is exposed at https://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 certificate 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>

Vedere anche

Riferimenti

BasicHttpMessageSecurity
Message
Message
BasicHttpMessageSecurityElement

Concetti

<associazione>

Altre risorse

Securing Services and Clients
Windows Communication Foundation Bindings
Configuring System-Provided Bindings
Using Bindings to Configure Services and Clients