eduardoboucas / staticman

💪 User-generated content for Git-powered websites
https://staticman.net
MIT License
2.41k stars 534 forks source link

RSA private key encoding too long #460

Open razonyang opened 1 year ago

razonyang commented 1 year ago

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 commented 9 months ago

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 commented 5 months ago

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