简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM