X509CertificateValidator Class
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 : X509CertificateValidator { string allowedIssuerName; public MyX509CertificateValidator(string allowedIssuerName) { if (allowedIssuerName == null) { throw new ArgumentNullException("allowedIssuerName"); } this.allowedIssuerName = allowedIssuerName; } public override void Validate(X509Certificate2 certificate) { // Check that there is a certificate. if (certificate == null) { throw new ArgumentNullException("certificate"); } // Check that the certificate issuer matches the configured issuer if (allowedIssuerName != certificate.IssuerName.Name) { throw new SecurityTokenValidationException ("Certificate was not issued by a trusted issuer"); } } }
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.