【发布时间】:2017-06-26 17:54:18
【问题描述】:
我对 SSL 证书不是很有经验,我希望有人可以帮助我找出我做错了什么。
我正在尝试使用自己的端口 (*:1729) 托管 NodeJS 应用程序,Apache2 在端口 443 上启用了 SSL(它从该端口为客户端应用程序提供服务,而不是相关的 NodeJS/Express/Socket.io 应用程序)。当我使用 http 设置 Express 时,它可以正常工作,我的客户端应用程序与 NodeJS 应用程序通信时不会出错,但是当我将 https 与 express 一起使用时,如下所示:
this.express = require('express');
this.app = this.express();
var https = require('https');
var fs = require('fs');
var sslPath = '/etc/letsencrypt/live/yourdomain.example.com/';
var options = {
key: fs.readFileSync(sslPath + 'privkey.pem'),
cert: fs.readFileSync(sslPath + 'fullchain.pem')
};
this.server = https.createServer(options, this.app);
this.io = require('socket.io').listen(this.server);
this.server.listen(1729);
当我的客户端应用程序尝试连接时,我会收到此错误:
node: ../src/util-inl.h:196: TypeName* node::Unwrap(v8::Local<v8::Object>) [with TypeName = node::TLSWrap]: Assertion ``(object->InternalFieldCount()) > (0)' failed.
Aborted (core dumped)
任何可以为我指明正确方向的建议或更正将不胜感激,谢谢!
【问题讨论】:
-
您使用的是哪个版本的 Node.js?
node --version -
我正在使用节点 v4.2.6