X509CertificateValidator.Validate(X509Certificate2) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
When overridden in a derived class, validates the X.509 certificate.
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)
Parameters
- certificate
- X509Certificate2
The X509Certificate2 that represents the X.509 certificate to validate.
Examples
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
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
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET