Skip to content
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

Webservice failed: Empty key #3

Open
zxdawn opened this issue Dec 20, 2022 · 2 comments
Open

Webservice failed: Empty key #3

zxdawn opened this issue Dec 20, 2022 · 2 comments

Comments

@zxdawn
Copy link

zxdawn commented Dec 20, 2022

Hi, I followed your tutorial and met this error when deploy the web service:

Dec 20 10:01:47 PM  Error: Empty key given
Dec 20 10:01:47 PM      at NodeRSA.module.exports.NodeRSA.importKey (/app/node_modules/node-rsa/src/NodeRSA.js:178:19)
Dec 20 10:01:47 PM      at Object.<anonymous> (/app/lib/RSA.js:6:5)
Dec 20 10:01:47 PM      at Module._compile (module.js:652:30)
Dec 20 10:01:47 PM      at Object.Module._extensions..js (module.js:663:10)
Dec 20 10:01:47 PM      at Module.load (module.js:565:32)
Dec 20 10:01:47 PM      at tryModuleLoad (module.js:505:12)
Dec 20 10:01:47 PM      at Function.Module._load (module.js:497:3)
Dec 20 10:01:47 PM      at Module.require (module.js:596:17)
Dec 20 10:01:47 PM      at require (internal/module.js:11:18)
Dec 20 10:01:47 PM      at Object.<anonymous> (/app/controllers/encrypt.js:4:13)

How did you set the GitHub key and value in render? I guess that's the possible cause.

@zxdawn zxdawn changed the title Empty key Webservice failed: Empty key Dec 20, 2022
@Synvani
Copy link

Synvani commented Dec 20, 2022

hey @zxdawn, in "Environment" tab you need to add:

GITHUB_APP_ID (not the Client ID, the APP ID from your GitHub app settings)
GITHUB_PRIVATE_KEY (you create it from the GitHub app settings, then it will be inside a .pem file you save on your computer)
RSA_PRIVATE_KEY (the private key you generate locally to encrypt secrets, "openssl genrsa" in cmd)

The above 3 environment vars worked for me and deployment finished successfully.

@zxdawn
Copy link
Author

zxdawn commented Dec 21, 2022

@Synvani Thanks! I set RSA_PRIVATE_KEY as KEY and the result of openssl genrsa | tr -d '\n' as VALUE. However, I got this error:

Dec 21 10:29:23 AM  Error [InvalidAsn1Error]: encoding too long
Dec 21 10:29:23 AM      at newInvalidAsn1Error (/opt/render/project/src/node_modules/asn1/lib/ber/errors.js:7:13)
Dec 21 10:29:23 AM      at Reader.readLength (/opt/render/project/src/node_modules/asn1/lib/ber/reader.js:102:13)
Dec 21 10:29:23 AM      at Reader.readSequence (/opt/render/project/src/node_modules/asn1/lib/ber/reader.js:135:16)
Dec 21 10:29:23 AM      at Object.privateImport (/opt/render/project/src/node_modules/node-rsa/src/formats/pkcs1.js:63:16)
Dec 21 10:29:23 AM      at Object.detectAndImport (/opt/render/project/src/node_modules/node-rsa/src/formats/formats.js:63:48)
Dec 21 10:29:23 AM      at module.exports.NodeRSA.importKey (/opt/render/project/src/node_modules/node-rsa/src/NodeRSA.js:185:22)
Dec 21 10:29:23 AM      at Object.<anonymous> (/opt/render/project/src/lib/RSA.js:6:5)
Dec 21 10:29:23 AM      at Module._compile (node:internal/modules/cjs/loader:1218:14)
Dec 21 10:29:23 AM      at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
Dec 21 10:29:23 AM      at Module.load (node:internal/modules/cjs/loader:1081:32)

Solution

Render needs PKCS1 format key, this trick works:

openssl genrsa > pk8key.pem
openssl pkcs8 -in pk8key.pem -traditional -nocrypt -out key.pem
cat key.pem | tr -d '\n'

New problem

Although it's deployed successfully, the website https://<**.onrender.com>/api-docs isn't accessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants