System.Net.Security.ProtectionLevel Enumeration

Specifies the level of protection to be applied to a message.

Syntax

public enum ProtectionLevel

Members

None: No protection is applied to the message.

Sign: The message is signed to ensure its integrity and authenticity.

EncryptAndSign: The message is encrypted to ensure confidentiality and signed to ensure integrity and authenticity.

Remarks

The ProtectionLevel enumeration is used to specify the desired level of security protection for messages exchanged between client and server applications. It is commonly used with Windows Communication Foundation (WCF) services and other .NET networking components.

When a communication channel is configured with a specific ProtectionLevel, the underlying security protocols (such as TLS/SSL) will enforce the specified protection mechanisms.

The choice of ProtectionLevel depends on the sensitivity of the data being transmitted and the security requirements of the application.

Applies to

Assembly Class Member
System.Net.Primitives ChannelProtectionRequirementsAttribute ProtectionLevel property
System.ServiceModel.Primitives ServiceCredentials MessageProtectionLevel property
System.ServiceModel.Primitives BasicHttpBinding Security.Message.ClientCredentialType and Security.Message.ProtectionLevel properties

Example Usage (WCF Binding Configuration)

<!-- Example for a binding configuration requiring encryption and signing -->
<customBinding>
  <binding name="secureBinding">
    <textMessageEncoding />
    <httpsTransport /> <!-- Or other transport like tcp -->
    <!-- Example with explicit security settings -->
    <security authenticationMode="MutualCertificate">
      <message protectionLevel="EncryptAndSign" />
    </security>
  </binding>
</customBinding>

In WCF, this is often configured through binding elements, where ProtectionLevel can be set on the message security or transport security.

See Also