Skip to content

How to pass in proper RSA key? #24

Description

@munjalpatel

Hello,

I am trying to verify a JWT token using RS256 and an RSA public key. However, I keep getting "ArgumentError"

What is the correct way to pass in RSA key?

This is what I am doing:

[{_, key, _}] = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n"
|> :public_key.pem_decode

token = "__header__.__payload__.__sig__"
JsonWebToken.verify(token, %{alg: "RS256", key: key})

This is the error I get:

** (ArgumentError) argument error
(crypto) :crypto.pkey_verify_nif(:rsa, :sha256, "header.payload.sig", <<7, 49, 241, 224, ..., 85, 4, 3, 19, ...>>, [])
(crypto) crypto.erl:420: :crypto.verify/6
(json_web_token) lib/json_web_token/jws.ex:103: JsonWebToken.Jws.verified/3
(json_web_token) lib/json_web_token/jwt.ex:89: JsonWebToken.Jwt.verify/2

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions