From 68fba260702876a9936205d0352c47b0b18c9687 Mon Sep 17 00:00:00 2001 From: Gil Pedersen Date: Wed, 4 Jan 2017 22:03:19 +0100 Subject: [PATCH] Support https protocol using any certificate Fixes #65 --- src/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2caba5051..e5efbafee 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import * as glob from 'glob'; import {Handles} from 'vscode-debugadapter'; import * as http from 'http'; +import * as https from 'https'; import * as logger from './logger'; @@ -205,7 +206,11 @@ export function errP(msg: string|Error): Promise { */ export function getURL(aUrl: string): Promise { return new Promise((resolve, reject) => { - http.get(aUrl, response => { + const parsedUrl = url.parse(aUrl); + const get = parsedUrl.protocol === 'https:' ? https.get : http.get; + const options = Object.assign({ rejectUnauthorized: false }, parsedUrl) as https.RequestOptions; + + get(options, response => { let responseData = ''; response.on('data', chunk => responseData += chunk); response.on('end', () => {