Skip to content

Misleading "invalid algorithm" error on malformed public key #882

Open

Description

@Drew-Kimberly

Description

On 9.0.0, we get the following error when trying to verify a JWT using a malformed public key:

JsonWebTokenError: invalid algorithm

In 8.x, we would get an error that would look something like:

Error: error:1E08010C:DECODER routines::unsupported
{
  library: 'DECODER routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_UNSUPPORTED'
}

The latter points us to a crypto error and suggests an issue parsing the key.
The former misleads the developer from the root issue.

The library should at least throw the original crypto error. Here is the line of code responsible for eating the error: https://github.com/auth0/node-jsonwebtoken/blob/master/verify.js#L123

Reproduction

https://github.com/Drew-Kimberly/jsonwebtoken-invalid-alg-repro
(uses dummy jwt/key from https://jwt.io)

Environment

  • Version of this library used: 9.0.0
  • Other relevant versions (language, server software, OS, browser): NodeJS 16.19.0 and 18.12.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions