shaithana
shaithana

Reputation: 2490

Load certificate and private key for SSL in Node.js

Sorry but I have no experience with certificates and SSL, especially in Node.js. I need to configure options for express:

var https = require('https');
var options = {
    key: fs.readFileSync('key.pem'),
    cert: fs.readFileSync('csr.pem')
};
https.createServer(options, my_app).listen(3000);

and if I try with self generated certificates (by openssl) all works like a charm.

Now, I need to change the self generated certificates with the true certificates for my domain. In Plesk I have 3 certificates: a CSR, a Private key (.key) and a Certificate (.crt) in text format, and this certificates are already working on the Plesk configuration of my server, so they are ok.

So, what I need to do now? Which of these is the key.pem and which is the csr.pem?

Sorry but I don't know, can anyone explain me?

Upvotes: 5

Views: 7323

Answers (1)

shokulei
shokulei

Reputation: 105

It should be this:

key: fs.readFileSync('FILENAME.key'),
cert: fs.readFileSync('FILENAME.crt')

CSR is the request you send to the trusted third party to get a signed certificate. You will receive a certificate back from the trusted third party, and that's what you use with the private key in NodeJS.

Upvotes: 2

Related Questions