MSDN Library

HostnameValidator Class

Namespace: System.Net.Security Created On: 2024-03-15 Last Updated: 2024-03-15

Summary

Defines the contract for hostname validators.

Syntax

public abstract class HostnameValidator

Remarks

The HostnameValidator class is an abstract base class that defines the contract for classes that validate hostnames. This class is used internally by the .NET Framework to validate hostnames during SSL/TLS certificate validation.

Concrete implementations of HostnameValidator can be provided to customize hostname validation behavior, for example, to support wildcard certificates or specific domain name matching rules. The default implementation provides standard hostname validation as per RFC specifications.

When an application uses an SSL/TLS connection, the server presents a certificate containing a hostname. The client-side SSL/TLS implementation must verify that this hostname matches the expected hostname of the server. The HostnameValidator class abstracts this validation process.

Inheritance Hierarchy

System.Object
System.Net.Security.HostnameValidator

Methods

Validate

public abstract bool Validate(string hostName, System.Security.Cryptography.X509Certificates.X509Certificate certificate)

When overridden in a derived class, validates the specified host name against the specified X.509 certificate.

Parameters

Name Description
hostName The host name to validate.
certificate The X.509 certificate to validate against.

Return Value

true if the host name is valid; otherwise, false.

Requirements

Requirement Description
Namespace System.Net.Security
Assembly System.dll
Framework Versions .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5, .NET Framework 4.0, .NET Framework 4.5, .NET Framework 4.5.1, .NET Framework 4.5.2, .NET Framework 4.6, .NET Framework 4.6.1, .NET Framework 4.6.2, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.7.2, .NET Framework 4.8, .NET Core 1.0, .NET Core 1.1, .NET Core 2.0, .NET Core 2.1, .NET Core 2.2, .NET Core 3.0, .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8

See Also