Rodrigo Pereira
Rodrigo Pereira

Reputation: 1924

How to setup an EV Certificate a node.js server

I've received four files from Comodo:

AddTrustExternalCARoot.crt
COMODORSAAddTrustCA.crt
COMODORSAExtendedValidationSecureServerCA.crt
mydomain.crt

This is my first time setting up a https server.

I know that I have to put on parameters that is passed to https.createServer but my problem is I don't know which one is the correct property.

Upvotes: 0

Views: 533

Answers (1)

mscdex
mscdex

Reputation: 106736

The server certificate is set as cert, whereas your CA certificates are set under ca:

var fs = require('fs'),
    https = require('https');

var cfg = {
  key: fs.readFileSync('/path/to/privatekey.pem'),
  cert: fs.readFileSync('/path/to/mydomain.crt'), // PEM format
  ca: [
    fs.readFileSync('/path/to/AddTrustExternalCARoot.crt'), // PEM format
    fs.readFileSync('/path/to/COMODORSAAddTrustCA.crt'), // PEM format
    fs.readFileSync('/path/to/COMODORSAExtendedValidationSecureServerCA.crt') // PEM format
  ]
};

https.createServer(cfg, function(req, res) {
  // ...
}).listen(443);

Or you can use just pfx if you have your key, cert, and ca files all bundled into a single PFX/PKCS12-formatted file.

Upvotes: 2

Related Questions