Skip to content

CertificateFailedValidation event is not logging the ChainErrors as expected. #44484

@jupacaza

Description

@jupacaza

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

https://github.com/dotnet/aspnetcore/blob/main/src/Security/Authentication/Certificate/src/CertificateAuthenticationHandler.cs#L155

In CertificateAuthenticationHandler line 155 you log event:
Logger.CertificateFailedValidation(clientCertificate.Subject, chainErrors);

but the chainErrors logs this:
System.Collections.Generic.List1[System.String]`

You need to log the values of the chainErrors. Otherwise this is not a helpful message.

Expected Behavior

Log the chain errors in the list.

Steps To Reproduce

Call a service using certificate authentication handler with a certificate that has a root that is not installed in the server. This should give chain errors. Check the logs and you'll see the chain errors are not logged properly.

From our service we see this event:
name: Microsoft.AspNetCore.Authentication.Certificate.CertificateAuthenticationHandler
body: Certificate validation failed, subject was {Subject}. {ChainErrors}
subject: CN=scrapped.net
chain errors: System.Collections.Generic.List`1[System.String]

Exceptions (if any)

No response

.NET Version

6.0.301

Anything else?

No response

Metadata

Metadata

Assignees

Labels

✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!area-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