X509CertificateValidator.Validate(X509Certificate2) Method

Definition

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

C#
public abstract void Validate (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);

Parameters

certificate
X509Certificate2

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

Examples

C#
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");
    }
}

Remarks

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 SecurityTokenValidationException.

Applies to

製品 バージョン
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)