Skip to content

OnAuthenticationFailed never fires when certificate validation fails #30819

Closed
@TheNephalim

Description

@TheNephalim

Description

I have a rooted certificate (created a CA and generated a test user certificate from this CA). When attempting to present this certificate, I fully expected the certificate validation to fail because it cannot check a CRL. This failure is desired. However, the handler associated with the OnAuthenticationFailed event never fires.

I stepped through the code in the CertificateAuthenticationHandler.cs and found that the certificate validation fails as expected, but reaches line 140 where the code states:

            return AuthenticateResult.Fail("Client certificate failed validation.");

and the AuthenticationFailed event and its associated event handler are never fired.

I changed the options.RevocationMode to X509RevocationMode.NoCheck. As expected, the validation of the certificate succeeds and reaches line 149 where the code states:

        await Events.CertificateValidated(certificateValidatedContext);

and the CertificateValidated event and associated handler are fired.

Configuration

.NET Core 3.1
Windows 10 Professional
x64 architecture

Regression?

I don't know if this is a regression.

Other information

N/A

Metadata

Metadata

Assignees

Labels

✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!DoneThis issue has been fixedarea-authIncludes: Authn, Authz, OAuth, OIDC, BearerbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions