Skip to content

NoMatchingKeys when there is clearly a matching key #152

@timas130

Description

@timas130

The situation I have is extremely weird, and has been haunting me for a few months at this point.

I use openidconnect to authenticate my users through Google. When the server starts, CoreProviderMetadata::discover_async is called, it downloads everything needed, and then the CoreClient is created using that. It is then stored immutably.

In my application the ID token is checked on the backend. This is mainly for compatibility reasons. All goes well for a while, but after some time passes (around a week), many users start to receive errors when trying to log in with Google. Looking at the logs, the error is SignatureVerification(NoMatchingKey). After I restart the server, the error goes away for everyone who had it.

So, I used tcpdump to record the login requests before and after the restart. What I found is that they are absolutely, byte-for-byte, identical, including the ID token. I also decoded them and checked the kid with the ones found on Google's jwks_url, and they match.

Here's a sample token (I replaced the data with {}):

eyJhbGciOiJSUzI1NiIsImtpZCI6IjU1YzE4OGE4MzU0NmZjMTg4ZTUxNTc2YmE3MjgzNmUwNjAwZThiNzMiLCJ0eXAiOiJKV1QifQ.e30.lpZ_ppAHoR1NKQb7GzOKAf9sXy4h6LFi2HW4BBAvUBBkJCVyfAxQofekgClIwpdQTBrP650A-izz84KiSGtWTqFm-9jVNx7_gJH3mCpwKR4xWCdVNlcD72KM62bm2hSTznMO9-jo7xjhh9kLBrN0dbFln9yc4t4TH_7SujyBfcKR2cdcaxWsFG7kIilrv45QWcoPebkoteLJPWRDkthIw-NWJQxrYjPpfG8zj_F6wNXSS_WoB5hWwJFyXUQLPsiDe_H3tIMBbNuFc_5yFyRcFBX4WeLGerKshgGptOn8CJSp-OR1rK5y4MBzCUS3D7Ag6brUs5ifuRfGne28tlGSOQ

Why does this happen? Does the JWK set expire after some time? Please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions