MessageProtectionOrder Wyliczenie

Definicja

Określa kolejność operacji, które chronią komunikat.

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

Pola

EncryptBeforeSign 2

Określa, że komunikat PROTOKOŁU SOAP jest szyfrowany przed wygenerowaniem podpisu cyfrowego dla komunikatu PROTOKOŁU SOAP.

SignBeforeEncrypt 0

Określa, że podpis cyfrowy jest generowany dla komunikatu PROTOKOŁU SOAP przed zaszyfrowanie jakiejkolwiek części komunikatu PROTOKOŁU SOAP, ale podpis cyfrowy nie jest szyfrowany.

SignBeforeEncryptAndEncryptSignature 1

Określa, że podpis cyfrowy jest generowany dla komunikatu PROTOKOŁU SOAP przed zaszyfrowaną częścią komunikatu PROTOKOŁU SOAP, a podpis cyfrowy jest szyfrowany.

Przykłady

Poniższy przykład tworzy SymmetricSecurityBindingElement element i ustawia jego MessageProtectionOrder właściwość na 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

Uwagi

To wyliczenie jest używane z AsymmetricSecurityBindingElement.MessageProtectionOrder właściwością AsymmetricSecurityBindingElement i SymmetricSecurityBindingElement.MessageProtectionOrder właściwością SymmetricSecurityBindingElement klas.

Jeśli komunikat jest narażony na atak szyfrowany (na przykład jeśli komunikat jest krótki lub entropia jest niska), użyj opcji SignBeforeEncryptAndEncryptAndEncryptSignature lub EncryptBeforeSigneSign. (Entropia to dane losowe udostępniane przez serwer, klienta lub oba te elementy i są używane do tworzenia klucza współużytkowanego do szyfrowania i odszyfrowywania danych).

Co jest uporządkowane?

Program WCF oferuje trzy różne poziomy ochrony, które określają sposób zabezpieczania komunikatów przy użyciu zabezpieczeń komunikatów protokołu SOAP. Wartość domyślna to SignBeforeEncryptAndEncryptSignature. To ustawienie najpierw podpisuje komunikat, szyfruje treść wiadomości, a następnie szyfruje podpis XML. Zmniejsza to prawdopodobieństwo pomyślnego ataku kryptograficznego na podpis.

Jednak użycie wartości domyślnej ma wpływ na wydajność. W efekcie istnieje kompromis w zakresie wydajności dla zwiększonego bezpieczeństwa. Szyfrowanie podpisu może zmniejszyć wydajność z zakresu od 10 procent do 40 procent. Jeśli zawartość danych komunikatu ma niską wartość, a przepływność wydajności jest bardziej znacząca, użyj polecenia SignBeforeEncrypt. Dzięki temu ustawieniu skrót podpisu jest wysyłany w postaci zwykłego tekstu, a tym samym komunikat jest bardziej podatny na ataki typu "guess-and-verify" na niską entropię.

Tylko powiązania niestandardowe

Aby zmienić właściwość, MessageProtectionOrder należy utworzyć niestandardowe powiązanie zabezpieczeń. Aby uzyskać więcej informacji na temat tworzenia powiązań niestandardowych, zobacz Tworzenie powiązań User-Defined. Aby uzyskać więcej informacji na temat tworzenia powiązania niestandardowego dla określonego trybu uwierzytelniania, zobacz How to: Create a SecurityBindingElement for a Specified Authentication Mode (Jak utworzyć element SecurityBindingElement dla określonego trybu uwierzytelniania).

Dotyczy

Zobacz też