累了,在Node上做了一个小服务器,开头是这样的:
var https = require('https');
var fs = require('fs');
var privateKey = fs.readFileSync('/etc/letsencrypt/live/******/privkey.pem', 'utf8');
var certificate = fs.readFileSync('/etc/letsencrypt/live/******/cert.pem', 'utf8');
var credentials = {
key: privateKey,
cert: certificate
};
var express = require('express');
var app = express();
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(8443);
var io = require('socket.io').listen(httpsServer);
io.sockets.on('connection', function(socket) { *** }
一开始一切都很好,:8443/socket.io/socket.io.js 可用,但是一旦涉及到握手,服务器就会崩溃并出现错误nodejs: ../src/util-inl.h:196: TypeName* node::Unwrap(v8::Local<v8::Object>) [with TypeName = node::TLSWrap]: Assertion
(object->InternalFieldCount()) > (0)'失败的。中止(核心转储)`端口已打开,证书正确,安装了必要的模块。有什么收获?