Node.js SSL:证书无效

Node.js SSL:证书无效

我正在尝试将 SSL 层应用到 node.js 服务器。

以下是我已完成的步骤

  1. 使用创建所有 SSL 资源博客
  2. 按照这里无需输入 pem 密码即可启动我的 node.js 服务器
  3. 我的 node.js 代码是

    var app = express();

    var 选项 = { 键:fs.readFileSync('。/sslCA/server.key'), 证书:fs.readFileSync('。/sslCA/server.crt'), ca:fs.readFileSync('。/sslCA/ca.crt'), requestCert:true,rejectUnauthorized:false };

    app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('视图引擎', 'jade'); app.set('视图选项', { layout: false}); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride());

    应用程序.使用(express.static(path.join(__dirname,'public')));

    https.createServer(options,app).listen(app.get('port'), function(){ console.log('Express 服务器正在监听端口 ' + app.get('port')); });

当我将 IE10 浏览器指向 localhost 时,出现错误

There is a problem with this website's security certificate.

The security certificate presented by this website is not secure.

Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server.  

We recommend that you close this webpage and do not continue to this website.  

当我将 Chrome 浏览器指向 localhost 时,出现错误

Invalid Server Certificate
You attempted to reach localhost, but the server presented an invalid certificate

请帮助我理解我做错了什么。

答案1

我解决了错误。

事实证明,从我的 server.key 中删除密码后,我必须重新生成服务器证书。

相关内容