Skip to content

Commit eccde0d

Browse files
committed
Move logic to check for certs when starting the debug service
Signed-off-by: worksofliam <[email protected]>
1 parent 340499b commit eccde0d

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/api/debug/index.ts

+24-14
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ export async function initialize(context: ExtensionContext) {
5858
}
5959
}
6060

61+
if (config.debugIsSecure) {
62+
if (!await certificates.localClientCertExists(connection)) {
63+
vscode.window.showInformationMessage(`Debug Service Certificates`, {
64+
modal: true,
65+
detail: `Debug client certificate is not setup.`
66+
},
67+
`Setup`
68+
).then(result => {
69+
if (result === `Setup`) {
70+
vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
71+
}
72+
});
73+
return;
74+
}
75+
}
76+
6177
if (password) {
6278
const debugOpts: DebugOptions = {
6379
password,
@@ -241,11 +257,6 @@ export async function initialize(context: ExtensionContext) {
241257
remoteCertsOk = true;
242258
remoteCertsAreNew = true;
243259
}
244-
245-
// Download the client certificates to the device if setup correctly.
246-
if (remoteCertsOk) {
247-
vscode.commands.executeCommand(`code-for-ibmi.debug.setup.local`);
248-
}
249260
} catch (e: any) {
250261
vscode.window.showErrorMessage(e.message || e);
251262
}
@@ -433,11 +444,10 @@ export async function initialize(context: ExtensionContext) {
433444
}
434445
}
435446
} else {
436-
const openTut = await vscode.window.showInformationMessage(`${
437-
existingDebugService ?
438-
`Looks like the Debug Service was started by an external service. This may impact your VS Code experience.` :
447+
const openTut = await vscode.window.showInformationMessage(`${existingDebugService ?
448+
`Looks like the Debug Service was started by an external service. This may impact your VS Code experience.` :
439449
`Looks like you have the debug PTF but don't have it configured.`
440-
} Do you want to see the Walkthrough to set it up?`, `Take me there`);
450+
} Do you want to see the Walkthrough to set it up?`, `Take me there`);
441451

442452
if (openTut === `Take me there`) {
443453
vscode.commands.executeCommand(`workbench.action.openWalkthrough`, `halcyontechltd.vscode-ibmi-walkthroughs#code-ibmi-debug`);
@@ -450,12 +460,12 @@ export async function initialize(context: ExtensionContext) {
450460
vscode.commands.executeCommand(`setContext`, `code-for-ibmi:debugManaged`, isManaged());
451461
}
452462

453-
function validateIPv4address(ipaddress: string) {
454-
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
455-
return (true)
463+
function validateIPv4address(ipaddress: string) {
464+
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
465+
return (true)
456466
}
457-
return (false)
458-
}
467+
return (false)
468+
}
459469

460470
interface DebugOptions {
461471
password: string;

0 commit comments

Comments
 (0)