Autocreate cetificate authority, detail in Chinese.
Download shell:
git clone https://github.com/barretlee/autocreate-ca.git;
cd autocreate-ca;
chmod +x *.sh;
Defatult install path: /root/ca
, you can replace it in the files below.
sh ./install-rootCA.sh
sh ./install-intermediateCA.sh
# fg. www.barretlee.com
sh ./install-websiteConfig.sh
Dblclick /root/ca/intermediate/certs/ca-chain.cert.pem
and install the certs.
Add one line to /etc/hosts
,www.barretlee.com
is the Common Name setted in file install-websiteConfig.sh
, you can change it.
127.0.0.1 www.barretlee.com
Then run the code below:
// https-server.js
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('/root/ca/intermediate/private/www.barretlee.com.key.pem'),
cert: fs.readFileSync('/root/ca/intermediate/certs/www.barretlee.com.cert.pem'),
passphrase: 'passoword' // 如果生成证书的时候设置了密码,请添加改参数和密码
};
https.createServer(options, function(req, res) {
res.writeHead(200);
res.end('hello world');
}).listen(8000, function(){
console.log('Open URL: https://www.barretlee.com:8000');
});
And you will see:
The detail of cert:
MIT.
Thanks for https://jamielinux.com/docs/openssl-certificate-authority/index.html.