1

I've purchased a Comodo SSL certificate to make SSL server with express. I have these files.

AddTrustExternalCARoot.crt
COMODORSAAddTrustCA.crt
COMODORSADomainValidationSecureServerCA.crt
mysite.com.key
mysite.com.csr
mysite_com.crt

According to a lot of documents I need .pem files. But nobody is saying what is that .pem files?

var options = {
  key: fs.readFileSync('/key.pem'),
  cert: fs.readFileSync('/cert.pem'),
  ca: fs.readFileSync('/ca.pem')
};

It'd be great if there is a tutorial.

user207421
  • 305,947
  • 44
  • 307
  • 483
Lazy
  • 1,807
  • 4
  • 29
  • 49
  • possible duplicate of [How to force SSL / https in Express.js](http://stackoverflow.com/questions/8605720/how-to-force-ssl-https-in-express-js) ([this answer](http://stackoverflow.com/a/11033289/) specifically) –  Nov 04 '14 at 19:47
  • According to that answer I need to create new `certrequest.csr`. But I already bought my Comodo SSL with `mysite.com.csr` – Lazy Nov 04 '14 at 20:11
  • This answer may be more helpful: http://stackoverflow.com/q/991758/ –  Nov 04 '14 at 21:05

2 Answers2

1

Try this answer. PEM is just a format than other SSL formats, and is very common.

Comodo may have already provided you a .pem file, but just named it .crt.
OR you may be able to request a .pem file in place of a DER-formatted file.
OR, you can use OpenSSL to convert from one format to another.

openssl rsa -inform DER -outform PEM -in mysite.com.key -out mysite.com.key.pem
openssl x509 -inform DER -outform PEM -in mysite.com.crt -out mysite.com.crt.pem
Community
  • 1
  • 1
ice13berg
  • 713
  • 8
  • 12
0

Simply start ssl OR simple way to use PEM NPM

var https = require('https'),
connect = require('connect'),
fs = require("fs");
var port = 3000;
var options = {
key: fs.readFileSync('/key.pem'),
cert: fs.readFileSync('/cert.pem'),
ca: fs.readFileSync('/ca.pem')
};
var app = express();
/* express setting */
server = require('https').createServer(options, app),
server.listen(port);

PEM npm is easiest way to start node server with SSL like

$> npm install pem

var https = require('https'),
pem = require('pem'),
express = require('express');

pem.createCertificate({days:1, selfSigned:true}, function(err, keys){
var app = express();


https.createServer({key: keys.serviceKey, cert: keys.certificate}, app).listen(443);
});
Muhammad Ali
  • 1,992
  • 1
  • 13
  • 20