# Invalid certificate from jwks for signing JWT

**URL:** <https://community.auth0.com/t/invalid-certificate-from-jwks-for-signing-jwt/8908>\
**Category:** Get Help\
**Tags:** certificate, jwks, access\_token, jwt\
**Created:** [December 7, 2017, 6:29pm UTC](https://community.auth0.com/t/invalid-certificate-from-jwks-for-signing-jwt/8908 "2017-12-07T18:29:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![justen](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@justen](https://community.auth0.com/u/justen)\
**Post date:** [December 7, 2017, 6:29pm UTC](https://community.auth0.com/t/invalid-certificate-from-jwks-for-signing-jwt/8908/1 "2017-12-07T18:29:39Z")

</div>

So this is for the situation where there is a change to the contents of the access\_token (eg. user updating name) which means i need to generate a new JWT access\_token.

- I have all the data for the new JWT
- I need to sign the new JWT with the certificate as the secret
- The way i get the certificate is by calling `jwksRsaClient.getSigningKey` which needs the `kid`
- the only way i can think of getting the `kid` is from the current token, so i decode the current JWT
- I retrieve the certificate back from `jwksRsaClient.getSigningKey`
- Use it to sign the token with `jwt.sign(data, certificate, {algorithm: 'RS256'})`

I get an error: `error:0906D06C:PEM routines:PEM_read_bio:no start line`  
When checking the certificate’s validity against openssl, it turns out the certificate is invalid.

Any help would be great

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [December 28, 2017, 8:59pm UTC](https://community.auth0.com/t/invalid-certificate-from-jwks-for-signing-jwt/8908/2 "2017-12-28T20:59:34Z")

</div>

I’m likely missing something, but if you’re using the Auth0 service as an identity provider/authorization server (aka token issuer) then in general the only entity that should be signing tokens is the service itself. In some situations (hint HS256) you may have the technical ability to sign tokens due to having the shared secret, but for RS256 this is more than just a theoretical guideline because you don’t even have access to the private key; only the matching public key is provided so you can validate issued tokens, but you can’t sign new one.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:57am UTC](https://community.auth0.com/t/invalid-certificate-from-jwks-for-signing-jwt/8908/3 "2018-03-02T05:57:40Z")

</div>


