Sdílet prostřednictvím


X509CertificateValidator.Validate(X509Certificate2) Metoda

Definice

Při přepsání v odvozené třídě ověří certifikát X.509.

public:
 abstract void Validate(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public abstract void Validate (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
abstract member Validate : System.Security.Cryptography.X509Certificates.X509Certificate2 -> unit
Public MustOverride Sub Validate (certificate As X509Certificate2)

Parametry

certificate
X509Certificate2

Představuje X509Certificate2 certifikát X.509 k ověření.

Příklady

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");
    }
}
    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
End Class

Poznámky

Přepište metodu Validate a určete způsob ověřování certifikátu X.509.

Pokud certifikát X.509 předaný do parametru certificate neprojde ověřením, vyvolá se SecurityTokenValidationException.

Platí pro