using node.js, i'd write code programmatically equivalent of following:
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 openssl rsa -passin pass:x -in server.pass.key -out server.key rm server.pass.key openssl req -new -key server.key -out server.csr openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
when complete, need rsa key server.key
, self-signed ssl certificate server.crt
.
forge
looks promising, far haven't figured out how work. have following code:
var pki = forge.pki; var keys = pki.rsa.generatekeypair(2048); var privkey = forge.pki.privatekeytopem(keys.privatekey); var pubkey = forge.pki.publickeytopem(keys.publickey);
but when write pubkey
file, i've noticed starts ...
-----begin public key----- miib... -----end public key-----
... , isn't recognized, whereas using openssl
above starts with:
-----begin certificate----- miid... -----end certificate-----
okay, realized, wasn't generating certificate. required quite bit more work, can find here. essentially, after bunch of setup, had create, sign, , convert certificate pem:
cert.sign(keys.privatekey); var pubkey = pki.certificatetopem(cert);
hope helps else!
Comments
Post a Comment