Skip to content

Commit 0b51df4

Browse files
committed
Option to disable ssl verification added
1 parent 036fcf3 commit 0b51df4

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ky-generator",
33
"displayName": "KY-Generator",
44
"description": "Visual Studio Code Extension for KY.Generator",
5-
"version": "1.0.2",
5+
"version": "1.0.3",
66
"publisher": "KY-Programming",
77
"icon": "images/128.png",
88
"repository": "https://github.com/KY-Programming/generator-vs-code",
@@ -29,7 +29,8 @@
2929
"compile": "tsc -p ./",
3030
"watch": "tsc -watch -p ./",
3131
"postinstall": "node ./node_modules/vscode/bin/install",
32-
"test": "npm run compile && node ./node_modules/vscode/bin/test"
32+
"test": "npm run compile && node ./node_modules/vscode/bin/test",
33+
"publish": "vsce publish"
3334
},
3435
"devDependencies": {
3536
"typescript": "^2.6.1",

src/extension.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,29 @@ export function activate(context: vscode.ExtensionContext) {
3838
const file = files[0];
3939
vscode.workspace.openTextDocument(file.fsPath).then(result => {
4040
const content = result.getText();
41-
debugger;
4241
let url: string;
42+
let strictSSL: boolean;
4343
if (content[0] === '{') {
4444
const configuration = JSON.parse(content);
4545
url = configuration.Generator.Connection;
46+
strictSSL = configuration.Generator.VerifySsl;
4647
}
4748
else {
4849
const start = content.indexOf('<Generator>') + 11;
4950
const end = content.indexOf('</Generator>');
5051
const generatorNode = content.substring(start, end);
5152
const connectionStart = generatorNode.indexOf('<Connection>') + 12;
52-
const connectionEnd = generatorNode.indexOf('</Connection>');
53+
const connectionEnd = generatorNode.indexOf('</Connection>');
5354
url = generatorNode.substring(connectionStart, connectionEnd).trim();
55+
const verifySslStart = generatorNode.indexOf('<VerifySsl>') + 11;
56+
const verifySslEnd = generatorNode.indexOf('</VerifySsl>');
57+
strictSSL = verifySslEnd === -1 || generatorNode.substring(verifySslStart, verifySslEnd).trim() !== 'false';
58+
}
59+
if (strictSSL === false) {
60+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
5461
}
5562
let id: string;
56-
http.post(url + '/Create', { configuration: content })
63+
http.post(url + '/Create', { configuration: content, })
5764
.then((response: any) => {
5865
id = response.data;
5966
return http.get(url + '/GetFiles/' + id);
@@ -76,10 +83,10 @@ export function activate(context: vscode.ExtensionContext) {
7683
});
7784
promises.push(promise);
7885
});
79-
return Promise.all(promises);
86+
return Promise.all(promises).then(() => filePaths.length);
8087
})
81-
.then(() => {
82-
vscode.window.showInformationMessage('Done');
88+
.then((count: number) => {
89+
vscode.window.showInformationMessage(count + ' files generated');
8390
})
8491
.catch((error: Error) => {
8592
vscode.window.showErrorMessage('Can not reach the generator server #231d\r\n' + error);

0 commit comments

Comments
 (0)