-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Creating RS256 signer from base64-encoded key #47
Comments
In the playground example, the HS256 algorithm was used where pretty much any byte array can be used as the secret. In RSA however, you need to provide the key data correctly. In this case, since the key is not automatically Base64-decoded, you should use |
Yep, that fixed it. Thanks. |
In my case (ES256), |
I think the problem is that the p8 file format is not directly supported (yet). However, you are able to create a token, right? That surprises me a bit.
I discovered that the documentation for JWT is not working. It was removed from the README here: 3932ea4#diff-04c6e90faac2675aa89e2176d2eec7d8
There is a section on creating ESCDSA keys there.
You should be able to convert your p8 to something the library understands using `openssl` but I don’t know the exact commands to use by heart.
@Tanner did something go wrong with the documentation migration or should the new documentation be written from scratch?
… On 13 Jun 2017, at 03:19, gaughyean ***@***.***> wrote:
In my case (ES256),
let url = URL.init(fileURLWithPath: "/Users/aamac/Desktop/HelloWorld/AuthKey_demoKey.p8")
let data = try Data.init(contentsOf: url)
I try let signer = ES256.init(key: data.makeBytes().base64Decoded) and let signer = ES256.init(key: data.makeBytes()) , but it didn't work. The token I create still don't work.. I got a http status code 500 from the response...
What's wrong with my codes? I can get the right token using a Python library, and get a http status code 200... @vzsg @sidmani @natebird Thank you !
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@siemensikkema I try to do this in the terminal: After that I copied the hex data(priv) and use the tools(http://tomeko.net/online_tools/hex_to_base64.php) to convert the key to base64 (U208KCg/doqiSzsVF5sknVtYSgt8/3oiYGbvryIRrzQ=), then I used the converted base64 string as a key to do this: |
Hmm, there must be some other difference then. Are the headers and payload exactly the same as the token you're creating with the Python library? |
thanks~ |
@gaughyean Any progress? I have the same issue |
It seems jwt doesn't support .p8 file..
I used python to get the token instead...
At 2017-07-18 19:17:47, "Adam" <notifications@github.com> wrote:
@gaughyean Any progress? I have the same issue
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Is there any progress for support p8 + ES256? |
I'm not aware of anyone succeeding with calling the Apple Music API with Vapor's JWT library 😞 |
I can't seem to get the library to create a JWT using the RS256 signer. I have some key that looks like this:
-----BEGIN PRIVATE KEY-----\nMIIEvA......a5efqA==\n-----END PRIVATE KEY-----\n
First, I removed the beginning and ending tags, and the \n's, so I have just the base64-key:
MIIEvA...a5efqA==
as a string. I then used the
.bytes
method (that was used in the playground example) to convert it to the correct type, and initialized the signer like so:let signer = try RS256(key: key.bytes)
However, this throws an error: "JWT error: Could not create key". Why is this? I tried using Data and Array to convert the string to [UInt8] as well, but that gave the same error. Is there a better way to create the signer object without doing the type conversion myself?
Thank you!
The text was updated successfully, but these errors were encountered: