AuthenticationPolicy Class

System.Net.Security

Defines the contract that security policy providers must implement to control client authentication.

Syntax

public abstract class AuthenticationPolicy

Remarks

The AuthenticationPolicy class is an abstract class used to define the policy for authenticating client credentials within the .NET Framework's network security services. It provides a mechanism for developers to implement custom authentication logic or to plug in existing security providers.

When you establish a secure connection using classes like SslStream or TcpClientSSL, you might need to specify an authentication policy to determine how clients are validated. The AuthenticationPolicy class serves as the base for these custom policies.

Key scenarios where you might use custom authentication policies include:

  • Implementing proprietary authentication mechanisms.
  • Integrating with existing enterprise security systems.
  • Enforcing specific certificate validation rules beyond the defaults.

To use a custom authentication policy, you typically create a class that inherits from AuthenticationPolicy and overrides its abstract methods. This derived class can then be provided to the relevant security classes during connection setup.

Methods

CreateClient #

public abstract ICertificatePolicy CreateClient()

Remarks

This method must be implemented by derived classes to return an instance of a class that implements the ICertificatePolicy interface. This policy is used for client-side certificate validation.

CreateServer #

public abstract ICertificatePolicy CreateServer()

Remarks

This method must be implemented by derived classes to return an instance of a class that implements the ICertificatePolicy interface. This policy is used for server-side certificate validation.

Inheritance Hierarchy

System.Object System.Net.Security.AuthenticationPolicy

Requirements

Namespace: System.Net.Security

Assembly: System (in System.dll)