Compartir a través de


<message> de <basicHttpBinding>

Define la configuración para la seguridad de nivel de mensaje de basicHttpBinding<>.

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security>
            <message>

Syntax

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

Atributos y elementos

En las secciones siguientes se describen los atributos, los elementos secundarios y los elementos primarios.

Attributes

Atributo Description
algorithmSuite Establece el cifrado de mensajes y los algoritmos de encapsulado de claves. Este atributo es de tipo SecurityAlgorithmSuite, que especifica los algoritmos y los tamaños de clave. Estos algoritmos se asignan a los especificados en la especificación lenguaje de directiva de seguridad (WS-SecurityPolicy).

El valor predeterminado es Basic256.
clientCredentialType Especifica el tipo de credencial que se va a usar al realizar la autenticación de cliente mediante la seguridad basada en mensajes. El valor predeterminado es UserName.

Atributo clientCredentialType

Importancia Description
Nombre de usuario - Requiere que el cliente se autentique en el servidor con una credencial UserName. Esta credencial debe especificarse mediante clientCredentials<>.
- WCF no admite el envío de una síntesis de contraseña ni la derivación de claves mediante contraseñas y el uso de estas claves para la seguridad del mensaje. Por lo tanto, WCF exige que el transporte se proteja al usar las credenciales UserName. basicHttpBindingPara , esto requiere configurar un canal SSL.
Certificate Requiere que el cliente se autentique en el servidor mediante un certificado. La credencial de cliente en este caso debe especificarse mediante <clientCredentials> y <clientCertificate>. Además, al usar el modo de seguridad de mensajes, el cliente debe aprovisionarse con el certificado de servicio. La credencial de servicio en este caso debe especificarse mediante ClientCredentials el elemento de clase o ClientCredentials comportamiento y especificar el certificado de servicio mediante <serviceCertificate>.

Elementos secundarios

Ninguno

Elementos primarios

Elemento Description
<seguridad> Define las funcionalidades de seguridad para basicHttpBinding<>.

Example

En este ejemplo se muestra cómo implementar una aplicación que usa basicHttpBinding y la seguridad de mensajes. En el ejemplo de configuración siguiente de un servicio, la definición del punto de conexión especifica basicHttpBinding y hace referencia a una configuración de enlace denominada Binding1. El certificado que el servicio usa para autenticarse en el cliente se establece en la behaviors sección del archivo de configuración en el serviceCredentials elemento . El modo de validación que se aplica al certificado que el cliente usa para autenticarse en el servicio también se establece en la behaviors sección debajo del clientCertificate elemento .

Los mismos detalles de enlace y seguridad se especifican en el archivo de configuración del cliente.

<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>

Consulte también