Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT - Invalid signature! when using es256 #95

Open
Akick opened this issue Sep 18, 2020 · 2 comments
Open

JWT - Invalid signature! when using es256 #95

Akick opened this issue Sep 18, 2020 · 2 comments
Labels
Milestone

Comments

@Akick
Copy link

Akick commented Sep 18, 2020

I`m creating a push notification for Apple (APNs). Code is simple:

-spec generate_token(binary(), binary(), string()) -> binary().
generate_token(TeamId, KeyId, KeyPath) ->
  PrivateJWK = jose_jwk:from_pem_file(KeyPath),
  JWK = jose_jwk:to_map(PrivateJWK),
  JWS = #{
    <<"alg">> => <<"ES256">>,
    <<"kid">> => KeyId
  },
  JWT = #{
    <<"iss">> => TeamId,
    <<"iat">> => apns_utils:epoch()
  },
  Signed = jose_jwt:sign(JWK, JWS, JWT),
  {_, Token} = jose_jws:compact(Signed),
  Token.

Key is *.p8

But apns answer with:

{403,[{<<"apns-id">>,<<"1294465C-E2AA-61D5-E49A-72E1A3C70BDC">>}],#{<<"reason">> => <<"InvalidProviderToken">>}}

I went to https://jwt.io and got the same answer.

What I do wrong?

@jbosse
Copy link

jbosse commented Mar 8, 2022

@Akick did you ever figure out the issue? I have the same problem.

@Akick
Copy link
Author

Akick commented Mar 8, 2022

@jbosse Yup. I used https://github.com/G-Corp/jwerl

@potatosalad potatosalad added the bug label Sep 1, 2022
@potatosalad potatosalad added this to the jose 1.12.0 milestone Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To do
Development

No branches or pull requests

3 participants