ssl (https)을 사용하는 내 사이트에서 사용할 보안 node.js 서버를 만들려고합니다. 내가 내 서버를 시작할 때Node.js HTTPS 보안 오류
const crypto = require('crypto'),
fs = require("fs"),
http = require("http");
var privateKey = fs.readFileSync('/home/privatekey.pem');
var certificate = fs.readFileSync('/home/certificate.pem');
var credentials = crypto.createCredentials({key: privateKey.toString(), cert: certificate.toString()});
var handler = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
var server = http.createServer();
server.setSecure(credentials);
server.addListener("request", handler);
server.listen(8084);
는하지만, 나는 다음과 같은 오류가 발생합니다 :
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object #<Server> has no method 'setSecure'
at Object.<anonymous> (/home/meshdev/public_html/js/node/server/test.js:16:8)
at Module._compile (module.js:380:26)
at Object..js (module.js:386:10)
at Module.load (module.js:312:31)
at Function._load (module.js:273:12)
at Array.<anonymous> (module.js:399:10)
at EventEmitter._tickCallback (node.js:108:26)
내 서버는 server.setSecure(credentials);
라인없이 잘 작동합니다. node.js (V0.4.1)를 실행 중입니다.
나는 어떤 제안이라도 고맙게 생각합니다.
감사합니다.
@schaermu - 답장을 보내 주셔서 감사합니다. 시작시 노드 서버가 오류를 반환하는 것을 막았지만 지금 클라이언트 측에 연결하면이 오류가 발생합니다. http://pastebin.com/ECf1fxLB 아이디어가 있습니까? – Kit
's.authorizationError'의 내용을 게시 할 수 있습니까? tls 핸드 셰이크가 실패하면 더 나은 오류 메시지가 표시되어야합니다 (문서에 따라). – schaermu
죄송합니다. 내 실수. 나는이 코드를 서버에 사용하고있다 : http://pastebin.com/FHmVpPS9. 클라이언트 측 연결을위한이 코드는 http://pastebin.com/xxcL7Rqv입니다. 노드 서버는 더 이상 오류가 없지만 클라이언트 측은 연결할 수 없습니다. – Kit