MessageProtectionOrder Enumeración

Definición

Especifica el orden de las operaciones que protegen un mensaje.

public enum class MessageProtectionOrder
public enum MessageProtectionOrder
type MessageProtectionOrder = 
Public Enum MessageProtectionOrder
Herencia
MessageProtectionOrder

Campos

EncryptBeforeSign 2

Especifica que se cifra el mensaje SOAP antes de que se genere una firma digital para el mensaje SOAP.

SignBeforeEncrypt 0

Especifica que una firma digital se genera para el mensaje SOAP antes de que se cifre cualquier parte del mensaje SOAP, pero no se cifra la firma digital.

SignBeforeEncryptAndEncryptSignature 1

Especifica que una firma digital se genera para el mensaje SOAP antes de que se cifre cualquier parte del mensaje SOAP y se cifra la firma digital.

Ejemplos

En el ejemplo siguiente se crea un SymmetricSecurityBindingElement elemento y se establece su MessageProtectionOrder propiedad en SignBeforeEncrypt.

public static Binding CreateCustomBinding()
{
    // Create an empty BindingElementCollection to populate,
    // then create a custom binding from it.
    BindingElementCollection outputBec = new BindingElementCollection();

    // Create a SymmetricSecurityBindingElement.
    SymmetricSecurityBindingElement ssbe =
        new SymmetricSecurityBindingElement();

    // Set the algorithm suite to one that uses 128-bit keys.
    ssbe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128;

       // Set MessageProtectionOrder to SignBeforeEncrypt.
    ssbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;

    // Use a Kerberos token as the protection token.
    ssbe.ProtectionTokenParameters = new KerberosSecurityTokenParameters();

    // Add the SymmetricSecurityBindingElement to the BindingElementCollection.
    outputBec.Add ( ssbe );
    outputBec.Add(new TextMessageEncodingBindingElement());
    outputBec.Add(new HttpTransportBindingElement());

    // Create a CustomBinding and return it; otherwise, return null.
    return new CustomBinding(outputBec);
}
Public Shared Function CreateCustomBinding() As Binding 
    ' Create an empty BindingElementCollection to populate, 
    ' then create a custom binding from it.
    Dim outputBec As New BindingElementCollection()
    
    ' Create a SymmetricSecurityBindingElement.
    Dim ssbe As New SymmetricSecurityBindingElement()
    
    ' Set the algorithm suite to one that uses 128-bit keys.
    ssbe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128
    
    ' Set MessageProtectionOrder to SignBeforeEncrypt.
    ssbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt
    
    ' Use a Kerberos token as the protection token.
    ssbe.ProtectionTokenParameters = New KerberosSecurityTokenParameters()
    
    ' Add the SymmetricSecurityBindingElement to the BindingElementCollection.
    outputBec.Add(ssbe)
    outputBec.Add(New TextMessageEncodingBindingElement())
    outputBec.Add(New HttpTransportBindingElement())
    
    ' Create a CustomBinding and return it; otherwise, return null.
    Return New CustomBinding(outputBec)

End Function

Comentarios

Esta enumeración se utiliza junto con la propiedad AsymmetricSecurityBindingElement.MessageProtectionOrder de AsymmetricSecurityBindingElement y la propiedad de SymmetricSecurityBindingElement.MessageProtectionOrder las clases SymmetricSecurityBindingElement.

Si un mensaje es vulnerable a un ataque de síntesis (por ejemplo, si el mensaje es corto o la entropía es bajo), debe usar la opción SignBeforeEncryptAndEncryptSignature o EncryptBeforeSign. (La entropía es datos aleatorios proporcionados por un servidor, un cliente o ambos, y se usa para crear una clave compartida para cifrar y descifrar datos).

¿Qué se ordena?

WCF ofrece tres niveles de protección diferentes que determinan cómo se protegen los mensajes mediante la seguridad de mensajes SOAP. El valor predeterminado es SignBeforeEncryptAndEncryptSignature. Este valor firma primero el mensaje, cifra el cuerpo del mensaje y, a continuación, cifra la firma XML. Esto reduce la probabilidad de un ataque de estimación criptográfico se realice con éxito contra la firma.

Sin embargo, utilizar el valor predeterminado tiene las implicaciones de rendimiento. En efecto, hay un intercambio de rendimiento para aumentar la seguridad. Cifrar la firma puede disminuir el rendimiento entre un 10 y un 40 por ciento. Si el contenido de datos del mensaje es de bajo valor y el rendimiento es más significativo, use SignBeforeEncrypt. Con este valor, el resumen de la firma se envía en texto no cifrado y así el mensaje es más vulnerable a los ataques suposición y comprobación de entropía baja.

Solo enlaces personalizados

Para cambiar la propiedad MessageProtectionOrder se requiere la creación de un enlace de seguridad personalizado. Para obtener más información sobre cómo crear enlaces personalizados, consulte Creación de enlaces de User-Defined. Para obtener más información sobre cómo crear un enlace personalizado para un modo de autenticación específico, vea How to: Create a SecurityBindingElement for a Specified Authentication Mode.

Se aplica a

Consulte también