-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
Unable to parse KeyObject for purpose of signing JWT with an EC private key. #85
Comments
I think my code doesn’t account for EC private keys that don’t include the public key in them. I’ll see what I can do, in the meantime, can you post the command that generated this key? |
This is your key's structure. The library expects it to be this, i.e. having the publicKey member. I have a fix for this for Node runtimes >= 12.0.0. I can't fix this for ^10.13.0 because i lack the functionality to compute the public key out of a private one and the extra code needed does seem like an overkill when all a person needs is to use lts/12 runtime. |
I was trying out some openssl commands to generate a private key that does not have a public key embedded. Tried this:
I am searching for a way to extra only the private key part from here. PS: The library works fine with the key embedded with the public key I generally generate the KeyPair using the Java security library:
Once you get the key pair, you can access the private key separately and extract the base64 encoded format using Java's util functions. |
I know. |
Only possible to handle when KeyObject API is available in the runtime. closes #85
Only possible to handle when KeyObject API is available in the runtime. closes #85
Thanks a lot @panva fo your quick support. :) |
Please consider supporting the library if it provides value to you or your company and this support was of help to you. Supporting the library means, amongst other things, that such support will be available in the future. |
I have been trying to read my EC private key from a file and use it to generate a signed JWT token. First I am putting my private key (a sample privateKey mentioned here) in the file
my_privatekey.txt
:Following is the code to read and create a signed JWT:
I am getting the following error in the step
JWK.asKey(keyObjCrypto, {'use': 'sig'})
:Not sure, what else I am missing.
Also, I tried verifying the key type using
openssl
command on terminal. Runningopenssl ec -in my_privatekey.txt -noout -text
outputs:on the terminal.
Can someone please help here?
The text was updated successfully, but these errors were encountered: