This documentation is archived and is not being maintained.

X509CertificateValidator Class

Validates an X.509 certificate.

Namespace:  System.IdentityModel.Selectors
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

Public MustInherit Class X509CertificateValidator
Dim instance As X509CertificateValidator

Use the X509CertificateValidator class to specify how an X.509 certificate is deemed valid. This can be done using by deriving a class from X509CertificateValidator and overriding the Validate method.

Public Class MyX509CertificateValidator
    Inherits X509CertificateValidator
    Private allowedIssuerName As String 

    Public Sub New(ByVal allowedIssuerName As String)
        If allowedIssuerName Is Nothing Then 
            Throw New ArgumentNullException("allowedIssuerName")
        End If 

        Me.allowedIssuerName = allowedIssuerName

    End Sub 'New 

    Public Overrides Sub Validate(ByVal certificate As X509Certificate2)
        ' Check that there is a certificate. 
        If certificate Is Nothing Then 
            Throw New ArgumentNullException("certificate")
        End If 

        ' Check that the certificate issuer matches the configured issuer 
        If allowedIssuerName <> certificate.IssuerName.Name Then 
            Throw New SecurityTokenValidationException("Certificate was not issued by a trusted issuer")
        End If 

    End Sub 'Validate
End Class 'MyX509CertificateValidator


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0