我正在尝试创建一个HTTPS服务器.我按照以下说明使用Cygwin64生成了privatekey.pem和certicate.pem:
openssl genrsa -out privatekey.pem 1024 openssl req -new -key privatekey.pem -out certrequest.csr openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
而我的服务器代码是这样的:
var https = require('https'); var fs = require('fs'); var options = { key: fs.readFileSync('privatekey.pem'), cert: fs.readFileSync('certificate.pem') }; https.createServer(options, function (req, res) { res.writeHead(200); res.end("hello world\n"); }).listen(8001);
当我尝试连接到地址时https://localhost:8001
,该网页不可用.谁能帮我?