-
Notifications
You must be signed in to change notification settings - Fork 34
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
getSignedJsonWebToken() yields error:0906D06C:PEM routines:PEM_read_bio:no start line #40
Comments
This doesn't seem like an issue with this package, since I have tested the same method as you, and no problem at all with this package or the upstream The following is my code that I have tested; const key = fs.readFileSync('./private-key.pem').toString();
const app = new App({ id: process.env.APP_ID, privateKey: key });
const jwt = app.getSignedJsonWebToken(); It seems as though the docs need updating, you don't need to do anything with the private key string |
I had the same issue with my PEM key set in env variable. I could dump the ENV, copy and paste the var into a node console, and everything would work - but somehow I would get this error in my logs. I'll keep playing with it and post again if I find the solution. |
Thank you, much appreciated |
Having the same issue. Saving to disk is not really an option I'm afraid. Need to read this from an ENV variable. |
Unfortunately this issue only comes up when using environment variables. The only thing we can do now is discourage their use until a solution can be found |
If someone could provide a reproducible test case that would be great. This package does not read out any environment variables, so the problem seems to be out of scope? Maybe log out the key before passing it to the |
Ok found it. Environment variables don't respect This works for me.
const app = new App({
id: process.env.GITHUB_APP_ID,
privateKey: process.env.GITHUB_APP_PRIVATE_KEY.replace(/\\n/g, '\n')
}) Sorry @gr2m had nothing to do with the repo or code. |
Thanks @tnolet, that's very helpful. As this might be a common mistake, I wonder if we can provide a more helpful error message? Maybe we can recognize the wrong formatting before trying to generate the JWT and throw a helpful error? |
@gr2m just add a little callout somewhere in the docs. That should be enough. Don't clutter the code with stuff that doesn't belong there. |
If only everyone would read the docs 😭 Maybe the fix is as simple as adding a |
In
changed it to
by removing the |
This library is being deprecated in favor of https://github.com/octokit/auth-app.js/. If anyone can reproduce the problem discussed here, I'd very much appreciate a pull request with a failing test to https://github.com/octokit/auth-app.js/ 🙏 |
As per this comment, the former library was deprecated in favour of the new one: octokit/app.js#40 (comment)
As per this comment, the former library was deprecated in favour of the new one: octokit/app.js#40 (comment)
Passing a PEM private key (in double quotes with line breaks replaced with \n, as shown in docs) to
app.getSignedJsonWebToken()
yields "error:0906D06C:PEM routines:PEM_read_bio:no start line". I'm using the function in a node lambda with a simple configuration:As a note, logging the app ID and private key does show them both being brought in correctly.
The text was updated successfully, but these errors were encountered: