系統:Windows 7Node.js的錯誤使用SSL UNABLE_TO_VERIFY_LEAF_SIGNATURE
版本的NodeJS:0.10.2
WS模塊:WS,最後一個版本
錯誤:
events.js:72 throw er; // Unhandled 'error' event ^ Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE at SecurePair. (tls.js:1283:32) at SecurePair.EventEmitter.emit (events.js:92:17) at SecurePair.maybeInitFinished (tls.js:896:10) at CleartextStream.read [as _read] (tls.js:430:15) at CleartextStream.Readable.read (_stream_readable.js:294:10) at EncryptedStream.write [as _write] (tls.js:344:25) at doWrite (_stream_writable.js:211:10) at writeOrBuffer (_stream_writable.js:201:5) at EncryptedStream.Writable.write (_stream_writable.js:172:11) at write (_stream_readable.js:547:24)
服務器:
(function(){
"use strict";
var fs = require('fs');
// you'll probably load configuration from config
var cfg = {
ssl: true,
port: 8080,
ssl_key: 'crt/server1.key',
ssl_cert: 'crt/server1.crt'
};
var httpServ = require('https')
var WebSocketServer = require('ws').Server;
var app = null;
// dummy request processing
var processRequest = function(req, res) {
res.writeHead(200);
res.end("All glory to WebSockets!\n");
};
if (cfg.ssl) {
app = httpServ.createServer({
// providing server with SSL key/cert
key: fs.readFileSync(cfg.ssl_key),
cert: fs.readFileSync(cfg.ssl_cert),
//requestCert: true,
//rejectUnauthorized: false
}, processRequest).listen(cfg.port);
} else {
app = httpServ.createServer(processRequest).listen(cfg.port);
}
// passing or reference to web server so WS would knew port and SSL capabilities
var wss = new WebSocketServer({ server: app });
wss.on('connection', function (wsConnect) {
wsConnect.on('message', function (message) {
console.log(message);
});
});
}());
客戶:
var WebSocket = require('ws');
var ws = new WebSocket('wss://localhost:8080');
ws.on('open', function() {
ws.send('something');
});
證書確認。
幫助>請!
檢查這個http://stackoverflow.com/questions/17200391/nodejs-unable-to-verify-leaf-signature – vinayr
我不行 –