2015-10-14 99 views
1

我是新来的NodeJS,我已经安装了Ubuntu上的NodeJS ,我必须从Comodo SSL证书以及当我启用了HTTPS的网站停止工作

我也跟着下面的步骤

1) Login to root account and copy the key file in SSL cert to /etc/ssl/private/private.key file. 
2) Then created file called /etc/ssl/certs/STAR_cert.com.crt and paste the contents of STAR_cert_com.crt into it. 

3) Then create file called /etc/ssl/certs/AddTrustExternalCARoot.crt file and paste all the contents of three files present inside "CA and Intermediate Certs" folder. 

而且从那以后,我配置了我的app.js文件follwoing

var sslOptions = { 
    key: fs.readFileSync('/etc/ssl/private/private.key'), 
    cert: fs.readFileSync('/etc/ssl/certs/STAR_cert_com.crt'), 
    requestCert: false, 
    //ca: fs.readFileSync('/etc/ssl/certs/AddTrustExternalCARoot.crt'), 
    rejectUnauthorized: false 
}; 

var secureServer = https.createServer(sslOptions,app).listen(443, function(){ 
    console.log("Express server listening on port : " + app.get('port')); 
    console.log("Mode : " + app.get('mode')); 
}); 

var http = require('http'); 
http.createServer(function (req, res) { 
    res.writeHead(301, { "Location": "https://" + req.headers['host'] + req.url }); 
    res.end(); 
}).listen(80); 
var secureServer = https.createServer(sslOptions,app).listen(443, function(){ 
    console.log("Express server listening on port : " + app.get('port')); 
    console.log("Mode : " + app.get('mode')); 
}); 

当我跑我的网站example.com它再导向ECTS到https://example.com,给我下面的错误

>  This webpage is not available 
>  
>  DNS_PROBE_FINISHED_NXDOMAIN 

但服务器控制台上没有错误。

如果我运行的网站没有HTTPS网站工作正常

任何想法?

感谢

回答

0

看来您已经添加了具有错误密钥的证书。 仔细检查文件及其密钥对。如果你有中间证书也包括这个。

1

你应该通过sslOption JSON作为串的密钥和证书参数,例如,你可以很容易地启动一个HTTPS使用快递4+服务器的NodeJS喜欢的东西:

希望它有助于!

+0

我试过了。同样的问题。 –

+0

您是否使用服务器IP地址代替域名获得相同的错误? –

+0

是的。我只是出于同样的错误 –

相关问题