-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Signing JWT with RSA private key loaded from .env file #191
Comments
The solution was to format my .env
Node-foreman will load the variables into the process, where they can be used seamlessly with the jsonwebtoken library as expected. |
I had the same issue and none of the answers given here or else where did not work. Finally I found out that one of the '-' in -----BEGIN RSA KEY----- was missing. There need to 5 dashes exactly. |
Hello,
I'd like to store my RSA private key in a .env file, and have it loaded into my node process via node-foreman, per best practice. The trouble is, the key format (PEM) spans multiple lines, which the .env file format doesn't allow. Based on workarounds posted by other folks, I've tried surrounding the key in double quotes and replacing line breaks with the line feed character ('\r'), but this results in an error:
.env
(this key is not used in any live system)
app.js
output
I've tried several permutations of this workaround without success. When loading the original private key file via the fs module and passing to this library, everything works perfectly as expected. Also, I've confirmed the key is being loaded into the
process.env.PRIVATE_KEY
variable in the exact same format as shown in the.env
file.So, how can I format the key in the .env file so that it will work as expected with this library?
Thanks in advance for your time.
The text was updated successfully, but these errors were encountered: