X509CertificateValidator.Validate(X509Certificate2) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
När det åsidosätts i en härledd klass validerar du X.509-certifikatet.
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)
Parametrar
- certificate
- X509Certificate2
Det X509Certificate2 som representerar X.509-certifikatet som ska verifieras.
Exempel
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
Kommentarer
Åsidosätt Validate metoden för att ange hur X.509-certifikatet ska verifieras.
När X.509-certifikatet som skickas till parametern certificate inte klarar valideringen genererar du SecurityTokenValidationException.