0

i want to create HTTPS server to my node.js socket.io server, did it with self sign certification, using this code

    var fs = require( 'fs' );
var app = require('express')();
var https        = require('https');
var server = https.createServer({
    key: fs.readFileSync('C:/ssl/ia.key'),
    cert: fs.readFileSync('C:/ssl/ia.crt'),
    requestCert: false,
    rejectUnauthorized: false
},app);
server.listen(8888);

but when purchasing real one i only get .crt file, how to secure my node app using it on windows server?

2 Answers2

0

Short answer: no private key - no way.

You need a private key that was used to purchase the certificate.

Or you can use letsencrypt-express:

Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.

https://www.npmjs.com/package/letsencrypt-express

stdob--
  • 28,222
  • 5
  • 58
  • 73
  • is there's a way to generate or get the private key from the purchased SSL ? already asked tech support of couple of websites selling SSL's and they cant give me private key, this is my big issue – DevMohammad Apr 21 '17 at 16:06
0

Found the answer, i had to do a CSR from my server using OPENSSL batch, in that case it will create CSR and the private KEY, buying SSL using the CSR will give me the CRT and i will use the generated key from the OPENSSL.