1. 建立certificate檔案
$ openssl genrsa -out pillaAuth-key.pem 1024 $ openssl req -new -key pillaAuth-key.pem -out certrequest.csr $ openssl x509 -req -in certrequest.csr -signkey pillaAuth-key.pem -out pillaAuth-cert.pem
2. 編輯JS如以下的檔案
var fs = require('fs');
var https = require('https');
var express = require('express');
var app = express();
var hskey = fs.readFileSync('pillaAuth-key.pem', utf8);
var hscert = fs.readFileSync('pillaAuth-cert.pem', utf8);
var credentials = {
key: hskey,
cert: hscert
};
https.createServer(credentials, app).listen(3001, function() {
console.log('Express https server listening on port ' + 3001);
});
文章標籤
全站熱搜
