X509CertificateValidator.Validate(X509Certificate2) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当在派生类中重写时,验证 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)
参数
- certificate
- X509Certificate2
表示要验证的 X.509 证书的 X509Certificate2。
示例
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
注解
重写 Validate 方法以指定对 X.509 证书进行验证的方式。
如果传入 certificate
参数的 X.509 证书未通过验证,则引发 SecurityTokenValidationException。