I have added the gatsby guess-js plugin, and have configured the jwt option. I have the pem key in .env.development, wrapped with quotes (the build fails without), which works fine on local builds.
However, when I try to deploy to Netlify the build fails, with the pem set as an environment variable - both with and without quotes. It fails with the error: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line.
@travisreynolds@futuregerald Any update here? Iām having this same issue attempting to communicate with the Github API as a Github App from Netlify Functions. Is it possible to use a PEM as an environment variable through the Netlify UI? Hereās my use case:
Iām using Githubās @octokit/app node package to create a JWT as follows: const APP_ID = process.env.GITHUB_APP_ID; const PRIVATE_KEY = process.env.GITHUB_PRIVATE_KEY; const app = new App({ id: APP_ID, privateKey: PRIVATE_KEY }); const jwt = app.getSignedJsonWebToken();
When I log the env variable, I do see exactly what I entered in the Netlify UI. Is there special formatting necessary for a multi-line variable?
Can you try BASE64 encoding the PEM key and storing the encoded version in an en var, then decoding it in your JS and using it that way? This may help getting around possible encoding problems.
Hi @futuregerald I was having the same problem, apparently my key was too big to be stored in an env variable. Then I followed your advice and base64 encoded it
Now Iām receiving an āinvalid grantā error from the auth server the key is supposed to authenticate to
The thing is, the same code works fine in local dev.
So, encoding the key works fine in local dev and the function authenticates, but in production it doesnāt
Any chance I should use a different encoding method?
Iāll post my encoding code here, in case it helps. The object I created has a āprivate_keyā property, see below
Looks identical to me from your screenshots. I canāt really explain what is happening on your other service. Perhaps you can ask them for help in seeing what is received, to see what is different?