Class System.Net.Security.AuthenticationPolicy

The System.Net.Security.AuthenticationPolicy class is an abstract class that defines the contract for classes that perform authentication for network services. It is used in conjunction with the System.Net.Security.SslStream class to customize the authentication process for secure network connections.

Inheritance Hierarchy

Object
  System.Net.Security.AuthenticationPolicy

Syntax

public abstract class AuthenticationPolicy

Requirements

Namespace:System.Net.Security

Assembly:System.Net.Security.dll

Framework Versions:

Remarks

When you need to implement custom authentication logic for your network applications, you can create a class that derives from AuthenticationPolicy. This class allows you to control how the server and client authenticate each other, typically using X.509 certificates.

The primary method you'll need to implement is Authenticate, which is responsible for performing the authentication handshake. You can also override other methods to provide more fine-grained control over the authentication process.

This class is abstract, meaning you cannot create an instance of it directly. You must create a concrete class that inherits from it and implements its abstract members.

Note: For most common scenarios, you can use the built-in authentication mechanisms provided by the .NET Framework, such as using the System.Net.Security.SslStream class with default certificate validation. Custom authentication policies are typically required for advanced security requirements or specific protocol implementations.

Members

Methods

public abstract bool Authenticate(string targetName, IAsyncResult asyncResult);

Authenticates the server or client asynchronously. (Abstract)

public abstract X509Certificate CreateServerCertificate(string targetName);

Creates a server certificate for the specified target name. (Abstract)

See Also

Security Warning: Implementing custom authentication policies requires careful consideration of security best practices. Incorrect implementation can lead to vulnerabilities. Always validate inputs and handle credentials securely.