diff --git a/CHANGELOG b/CHANGELOG index 22d2022..a6a15ae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +10 Feb 2015: anyproxy 3.2.1: + + * bugfix for 3.2.0 + 10 Feb 2015: anyproxy 3.2.0: * using SNI when intercepting https requests diff --git a/lib/httpsServerMgr.js b/lib/httpsServerMgr.js index eb5148f..ffc66d5 100644 --- a/lib/httpsServerMgr.js +++ b/lib/httpsServerMgr.js @@ -6,10 +6,13 @@ var getPort = require('./getPort'), fs = require('fs'), net = require('net'), tls = require('tls'), + crypto = require('crypto'), color = require('colorful'), certMgr = require("./certMgr"), asyncTask = require("async-task-mgr"); +var createSecureContext = tls.createSecureContext || crypto.createSecureContext; + //using sni to avoid multiple ports function SNIPrepareCert(serverName,SNICallback){ var keyContent, crtContent,ctx; @@ -28,7 +31,7 @@ function SNIPrepareCert(serverName,SNICallback){ }, function(callback){ try{ - ctx = tls.createSecureContext({ + ctx = createSecureContext({ key :keyContent, cert :crtContent }); @@ -43,7 +46,8 @@ function SNIPrepareCert(serverName,SNICallback){ console.log(color.yellow(color.bold("[internal https]")) + color.yellow(tipText)); SNICallback(null,ctx); }else{ - console.log("err occurred when prepare certs for SNI - " + e); + console.log("err occurred when prepare certs for SNI - " + err); + console.log("you may have to upgrade your Node.js to the lastest version"); } }); } @@ -57,9 +61,16 @@ module.exports =function(config){ throw(new Error("please assign a port")); } - https.createServer({ - SNICallback : SNIPrepareCert - },config.handler).listen(config.port); + certMgr.getCertificate("anyproxy_internal_https_server",function(err,keyContent,crtContent){ + + https.createServer({ + SNICallback : SNIPrepareCert , + key : keyContent, + cert : crtContent + },config.handler).listen(config.port); + + }); + } diff --git a/lib/requestHandler.js b/lib/requestHandler.js index bda9ff7..8e28340 100644 --- a/lib/requestHandler.js +++ b/lib/requestHandler.js @@ -303,7 +303,7 @@ function connectReqHandler(req, socket, head){ callback(); }else{ - proxyPort = 443; + proxyPort = (targetPort == 8003)?8003:443; //ws proxyHost = host; callback(); diff --git a/package.json b/package.json index e6f8246..6c7af0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "3.1.2", + "version": "3.2.1", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": {