diff --git a/.gitignore b/.gitignore index eef9b26..c5fc218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ test/ +yarn.lock -npm-debug.log \ No newline at end of file +npm-debug.log diff --git a/index.js b/index.js index a09fe0c..bfbdb6b 100644 --- a/index.js +++ b/index.js @@ -146,9 +146,10 @@ function CASAuthentication(options) { this.cas_url = options.cas_url; var parsed_cas_url = url.parse(this.cas_url); + this.request_client = parsed_cas_url.protocol === 'http:' ? http : https; this.cas_host = parsed_cas_url.hostname; - this.cas_port = parsed_cas_url.protocol === 'http:' ? 80 : 443; + this.cas_port = parsed_cas_url.port || (parsed_cas_url.protocol === 'http:' ? 80 : 443); this.cas_path = parsed_cas_url.pathname; this.service_url = options.service_url; @@ -335,6 +336,10 @@ CASAuthentication.prototype._handleTicket = function(req, res, next) { }; } + if (this.request_client === https && process.env.NODE_TLS_REJECT_UNAUTHORIZED != 0) { + process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0; + } + var request = this.request_client.request(requestOptions, function(response) { response.setEncoding( 'utf8' ); var body = ''; diff --git a/package.json b/package.json index c2d92db..c0f3120 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "xml2js": "^0.4.8" }, "devDependencies": { - "express": "^4.12.3", - "express-session": "^1.11.1" + "express": "^4.16.2", + "express-session": "^1.15.6" } }