This documentation is archived and is not being maintained.
X509CertificateValidator Class
Visual Studio 2008
Validates an X.509 certificate.
Assembly: System.IdentityModel (in System.IdentityModel.dll)
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
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.
Show: