0

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.

Nicholas Smith
  • 674
  • 1
  • 13
  • 27
Rodrigo Pereira
  • 1,834
  • 2
  • 17
  • 35

1 Answers1

2

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.

mscdex
  • 104,356
  • 15
  • 192
  • 153
  • i got these file files any help `AddTrustExternalCARoot.crt, ComodoUTNSGCCA.crt, EssentialSSLCA_2.crt, UTNAddTrustSGCCA.crt STAR_wsicloud_com.crt` – Max Nov 23 '15 at 14:05
  • This doesn't answer initial question. He has no key nor pem file. – Stepan Yakovenko Jan 31 '22 at 15:53