cdbattags / lua-resty-jwt

JWT For The Great Openresty
Apache License 2.0
146 stars 44 forks source link

sign rs256 ERROR: error in error handling #31

Closed Michael-LiK closed 4 years ago

Michael-LiK commented 4 years ago

i use lua-resty-jwt sign rs256 like this: -------------------- code ------------------------------ local table_of_jwt = { header = { typ = "JWT", alg = "RS256", }, payload = { iss = "aaa@aaa.iam.gserviceaccount.com", scope = "https://www.googleapis.com/auth/devstorage.read_only", aud = "https://oauth2.googleapis.com/token", exp = 1589025025, iat = 1589023025 } } local key = '---BEGIN PRIVATE KEY----- ---END PRIVATE KEY-----' local jwt_token = jwt:sign(key, table_of_jwt) print(jwt_token)

-------------------- code ------------------------------ the first result is https://github.com/cdbattags/lua-resty-jwt/issues/30 the fffonion help my solve it ,but now i use rs256, it doesn't work the result is ERROR: error in error handling

Michael-LiK commented 4 years ago

Hello? Anyone here?

cdbattags commented 4 years ago

Please add a PR for a breaking test case! Much easier to solve and will automatically Travis build so we can explore!

Michael-LiK commented 4 years ago

ok,i will add a PR for this case

Michael-LiK commented 4 years ago

sorry, i think use the lib with wrong ways, the signature key i use it wrong. ------example---------- Right ex: local key = ''-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w\n-----END PRIVATE KEY-- ---"

Wrong ex: local key = ''-----BEGIN PRIVATE KEY-----MIIEvQIBADANBgkqhkiG9w-----END PRIVATE KEY-- ---" ------example----------

I created the mistakes because i write wrong key , the evp.lua tell can't find start_line, then i find it. And i have a suggest, the lua-resty-jwt error can't tell the wrong reasons, i use hmac.lua and evp.lua by myself find the reasons.

cdbattags commented 4 years ago

Please feel free to add a PR to help those that come after you. Sorry, I'm trying to be hands off as much as possible maintaining this project.