mod/lti/token.php returns "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

mod/lti/token.php returns "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

J Samson -
Erantzun kopurua: 3

Hello,

I am working on an LTI tool to return grades to Moodle. For that, I need a JWT token for the current user signed with RS256. When I want to send the token I created to "/mod/lti/token.php", I get the following exception code: 

{

"error": "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

}

When I look around the internet it seems that the keys are not valid. But when I use https://jwt.io/, I can see the payload inside the token. 

This is the token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0IiwiaWF0IjoiMTY1MDg5MzQwOSIsImV4cCI6IjE2NTA4OTM3MDkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0L21vZC9sdGkvdG9rZW4ucGhwIiwic3ViIjoib0lXWkczeERMbDY0d0hzIn0.D_wNeLdYQqFz1ig4Gjr6SmyD-JnEuamYl05MdpdG4MjEJFPtVQdML-nCroDmaS9KrwYBCFUpecX8wMOoqSv3_pNA-v91hN3xURWsaiHHthH-SAR2Bb3k2YXST-_-ble_SVDBZ4g7M5mdlVrO9jVdgFvm7dlUILiJeqGa__6Nqf71ZDvizRn5HRC64YyoB7XLfVBIWbCvbqUKiuZcekuR5t9QLuL_VQyVuiKPW8pOxowpmZJOVmjDcmW-g2cTAAjf1dE4YmOiVFbOvEvqU0ha4sckRfNnY3y28eSzH-3HUvkh7jz8DuHKanGpzdrTk2NIZsntfMcBBEyvwhRJPNxklg



Puntuazioen batez bestekoa:Useful (1)
J Samson(e)ri erantzunda

Re: mod/lti/token.php returns "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

Antoni Bertran Bellido -
Hi, did you solve this issue, we currently have a similar one with one of our clients

we focus on error on shared RSA KEY
remember has to be with

-----BEGIN PUBLIC KEY-----
MIICIjANBgk......
-----END PUBLIC KEY-----

Best regards
Antoni Bertran Bellido(e)ri erantzunda

Re: mod/lti/token.php returns "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

J Samson -
I did solve it, but I can't remember the reason for this exception....
It might be that the KeyId was missing from the header in the JWT token. That Id should be used in the public and private key as well.
Antoni Bertran Bellido(e)ri erantzunda

Re: mod/lti/token.php returns "OpenSSL error: error:0909006C:PEM routines:get_name:no start line"

Carlos Barbosa -
Spot on! Was also getting this error due to an invalid key, used an online tool to convert my JWK to the PEM format and started working.