X509CertificateValidator.Validate Method (X509Certificate2)


When overridden in a derived class, validates the X.509 certificate.

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

Public MustOverride Sub Validate (
	certificate As X509Certificate2


Type: System.Security.Cryptography.X509Certificates.X509Certificate2

The X509Certificate2 that represents the X.509 certificate to validate.

Override the Validate method to specify how the X.509 certificate is validated.

When the X.509 certificate that is passed into the certificate parameter does not pass validation, throw the T:System.IdentityModel.Tokens.SecurityTokenvalidationException.

    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

.NET Framework
Available since 3.0
Return to top