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

RSA private key encoding too long #460

Open
razonyang opened this issue May 11, 2023 · 2 comments · May be fixed by eduardoboucas/staticman.net#30
Open

RSA private key encoding too long #460

razonyang opened this issue May 11, 2023 · 2 comments · May be fixed by eduardoboucas/staticman.net#30

Comments

@razonyang
Copy link

razonyang commented May 11, 2023

The doc about generating RSA private key seems out of date - https://staticman.net/docs/getting-started.html#step-2-deploy-staticman.

This works for me (OpenSSL v3).

openssl genrsa -traditional
@aleksandr-vin
Copy link

Does not work for me.

Tried both (with -traditional and without). Still fails when running on fly.io:

2023-12-12T17:54:35.221 app[56833260f61738] ams [info] > staticman@3.0.0 prestart /app
2023-12-12T17:54:35.221 app[56833260f61738] ams [info] > if [ ! -d node_modules ]; then npm install; fi
2023-12-12T17:54:35.235 app[56833260f61738] ams [info] > staticman@3.0.0 start /app
2023-12-12T17:54:35.235 app[56833260f61738] ams [info] > node index.js
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] { InvalidAsn1Error: encoding too long
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at newInvalidAsn1Error (/app/node_modules/node-rsa/node_modules/asn1/lib/ber/errors.js:7:13)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Reader.readLength (/app/node_modules/node-rsa/node_modules/asn1/lib/ber/reader.js:102:13)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Reader.readSequence (/app/node_modules/node-rsa/node_modules/asn1/lib/ber/reader.js:135:16)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Object.privateImport (/app/node_modules/node-rsa/src/formats/pkcs1.js:63:16)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Object.detectAndImport (/app/node_modules/node-rsa/src/formats/formats.js:63:48)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at NodeRSA.module.exports.NodeRSA.importKey (/app/node_modules/node-rsa/src/NodeRSA.js:185:22)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Object.<anonymous> (/app/lib/RSA.js:6:5)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Module._compile (module.js:652:30)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Object.Module._extensions..js (module.js:663:10)
2023-12-12T17:54:35.750 app[56833260f61738] ams [info] at Module.load (module.js:565:32) name: 'InvalidAsn1Error', message: 'encoding too long' }

@wrobelda
Copy link

Try with openssl genrsa -traditional | sed '$!s/$/\\n/' | tr -d '\n'

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

Successfully merging a pull request may close this issue.

3 participants