-
Notifications
You must be signed in to change notification settings - Fork 179
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
no start line - RS256 #7
Comments
got this, i'll look at it in few hours. |
Has it been resolved? I am getting the same reason "no start line". If I remove the start line of the key, I get "wrong tag" |
For all the poor lost souls out there, who were brought up here by google search: no start line - in this case I needed a certificate file rather than a public key. Turn your public key in certificate and you are good to go! |
thanks @tanica ! |
We knew this was a solution, but with other libraries (and indeed jwt.io) it's not a requirement. |
Is there an example of how people here accomplished this? I have the same problem as @freman. I'd love to know how @tanica went about creating a certificate file from a public key. Also, how are you passing in that file to the verify function? Are you reading it with io.read and saving that to a variable? Thanks. |
@tanica @swynter-ladbrokes @SkyLothar - I'm working with Nick, so just adding more to his question as we've found ourselves a bit up against the clock... we've tried all kinds of different openssl calls to try to generate a crt from a pem, but are seeing the same "no start line" error from openssl when we try that. And we've been searching online for how-to's but can't seem to find anything that works for going from a public key to a cert. We know we've at least got the pem generally right as we can use it to perform a working validity check in node. We're also guessing that the requirement here is not that the key is read specifically from a file in the lua code, but rather the reference to a cert file has to do with how the data is converted... and that if we wanted (though not really desired) we could hardcode the resultant content of a cert into our lua module variable directly and it should still work. Is that correct? But the primary question is still specifically how can we covert our pem key to the necessary form that this module requires. Thanks in advance for any help!! |
So I created a shell script in which I put these commands, because I needed some different types of keys. Here is what I had: #!/bin/bash openssl req -new -days 3600 -key $KEYNAME.pem -out pubcert The file you will need to use will be called certificate. Run the script like this: ./shell_script.sh mykeyname |
Is there any movement on this? Or has anyone been able to convert a PEM public key to a format accepted by this library? |
Both tanica & atanasova users are me, I posted the reply with my work account. The shell script above should work! good luck! |
@atanasova Thanks! That's a great script to create a new cert and all the associate assets and that will work well for testing. However, unless I'm missing something, I don't think that solves the issue of converting an existing PEM to a certificate that can be used. I need to use a PEM public key I've been given. So either I need to convert it to a format that this library takes or I need to modify the library to accept the PEM. |
unfortunately no, it won't work with PEM. You can use openssl to convert to Certificate. Unfortunately this is the only Lua lib I found that will validate RSA keys |
i ran into this problem as well - luckily i had access to the private key and could generate a certificate. I do think the library should accept a public key, though. it looks like all it does with the certificate is get a public key from it: https://github.com/SkyLothar/lua-resty-jwt/blob/master/lib/resty/evp.lua. so maybe the fix isn't too bad? |
I've made some mods to make this work you are welcome to try. Just use as normal but pass in your public_key (PEM string): local jwt_obj = jet:verify(public_key, jwt_token) It has worked for me, but I haven't spent much time testing it. |
@theganyo - I've pulled down your fork since I need to do some verification of the JWT using the PEM file. From what I have tested it seems to work. |
@clwang Great! Thanks for verifying! |
Greetings.
I'm not sure if it's something I'm completely borking up, but I can't see another way to do it.
We use your library to send JWT's from our frontends to our backends out of paranoia - this is working great, php has no trouble decoding these.
I am now trying to use your library to accept a JWT from a different provider (encoded with go-jwt)
This is the public key
This is the token
This is the output
And this is how I get that
The debug tool at jwt.io says it's a verified signature but this library won't verify it saying "no start line"
Any help?
The text was updated successfully, but these errors were encountered: