X509CertificateValidator.Validate(X509Certificate2) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Quando sobrescrito numa classe derivada, valida o certificado 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)
Parâmetros
- certificate
- X509Certificate2
O X509Certificate2 que representa o certificado X.509 a validar.
Exemplos
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
Observações
Substitua o Validate método para especificar como o certificado X.509 é validado.
Quando o certificado X.509 que é passado para o certificate parâmetro não passa a validação, lança o SecurityTokenValidationException.