Skip to content

Commit 5754257

Browse files
authored
Merge pull request #1923 from codefori/feature/sep_support
SEP support
2 parents 236d0eb + 38a8243 commit 5754257

File tree

6 files changed

+265
-99
lines changed

6 files changed

+265
-99
lines changed

package.json

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,14 @@
375375
"default": "8005",
376376
"description": "Port to connect to IBM i Debug Service."
377377
},
378+
"debugSepPort": {
379+
"type": "string",
380+
"default": "8008",
381+
"description": "Port to connect to IBM i Debug Service for SEP."
382+
},
378383
"debugIsSecure": {
379384
"type": "boolean",
380-
"default": false,
385+
"default": true,
381386
"description": "Used to determine if the client should connect securely or not."
382387
},
383388
"debugUpdateProductionFiles": {
@@ -956,16 +961,17 @@
956961
"enablement": "code-for-ibmi:connected && code-for-ibmi:debugManaged != true"
957962
},
958963
{
959-
"command": "code-for-ibmi.debug.activeEditor",
960-
"title": "Start Debugging Active Source",
964+
"command": "code-for-ibmi.debug.batch",
965+
"title": "Debug as Batch",
961966
"category": "IBM i",
962967
"icon": "$(debug-alt)",
963968
"enablement": "code-for-ibmi:connected"
964969
},
965970
{
966-
"command": "code-for-ibmi.debug.program",
967-
"title": "Debug Program",
971+
"command": "code-for-ibmi.debug.sep",
972+
"title": "Set Service Entry Point",
968973
"category": "IBM i",
974+
"icon": "$(debug-alt)",
969975
"enablement": "code-for-ibmi:connected"
970976
},
971977
{
@@ -1749,6 +1755,11 @@
17491755
{
17501756
"id": "code-for-ibmi.openMember",
17511757
"label": "Open"
1758+
},
1759+
{
1760+
"id": "code-for-ibmi.debug.group",
1761+
"label": "Start Debugging",
1762+
"icon": "$(debug-start)"
17521763
}
17531764
],
17541765
"menus": {
@@ -1785,6 +1796,14 @@
17851796
"when": "viewItem == member"
17861797
}
17871798
],
1799+
"code-for-ibmi.debug.group": [
1800+
{
1801+
"command": "code-for-ibmi.debug.batch"
1802+
},
1803+
{
1804+
"command": "code-for-ibmi.debug.sep"
1805+
}
1806+
],
17881807
"commandPalette": [
17891808
{
17901809
"command": "code-for-ibmi.userLibraryList.enable",
@@ -2047,7 +2066,11 @@
20472066
"when": "never"
20482067
},
20492068
{
2050-
"command": "code-for-ibmi.debug.program",
2069+
"command": "code-for-ibmi.debug.batch",
2070+
"when": "never"
2071+
},
2072+
{
2073+
"command": "code-for-ibmi.debug.sep",
20512074
"when": "never"
20522075
},
20532076
{
@@ -2236,7 +2259,7 @@
22362259
],
22372260
"editor/title": [
22382261
{
2239-
"command": "code-for-ibmi.debug.activeEditor",
2262+
"submenu": "code-for-ibmi.debug.group",
22402263
"when": "code-for-ibmi:connected && !inDebugMode && editorLangId =~ /^rpgle$|^rpg$|^cobol$|^cl$/i",
22412264
"group": "navigation@1"
22422265
},
@@ -2438,8 +2461,8 @@
24382461
"group": "1_workspace@1"
24392462
},
24402463
{
2441-
"command": "code-for-ibmi.debug.program",
2442-
"when": "view == objectBrowser && !inDebugMode && viewItem =~ /^object.pgm.*/",
2464+
"submenu": "code-for-ibmi.debug.group",
2465+
"when": "view == objectBrowser && !inDebugMode && (viewItem =~ /^object.pgm.*/ || viewItem =~ /^object.srvpgm.*/)",
24432466
"group": "2_debug@1"
24442467
},
24452468
{

src/api/Configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export namespace ConnectionConfiguration {
5555
showDescInLibList: boolean;
5656
debugCertDirectory: string;
5757
debugPort: string;
58+
debugSepPort: string;
5859
debugIsSecure: boolean;
5960
debugUpdateProductionFiles: boolean;
6061
debugEnableDebugTracing: boolean;
@@ -137,6 +138,7 @@ export namespace ConnectionConfiguration {
137138
showDescInLibList: (parameters.showDescInLibList === true),
138139
debugCertDirectory: (parameters.debugCertDirectory || DEFAULT_CERT_DIRECTORY),
139140
debugPort: (parameters.debugPort || "8005"),
141+
debugSepPort: (parameters.debugSepPort || "8008"),
140142
debugIsSecure: (parameters.debugIsSecure === true),
141143
debugUpdateProductionFiles: (parameters.debugUpdateProductionFiles === true),
142144
debugEnableDebugTracing: (parameters.debugEnableDebugTracing === true),

src/api/debug/certificates.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ function getLegacyCertificatePath() {
6565
return path.posix.join(LEGACY_CERT_DIRECTORY, SERVER_CERTIFICATE);
6666
}
6767

68+
function getPasswordForHost(connection: IBMi) {
69+
return connection.currentHost;
70+
}
71+
6872
export function getRemoteServerCertificatePath(connection: IBMi) {
6973
return path.posix.join(getRemoteCertificateDirectory(connection), SERVER_CERTIFICATE);
7074
}
@@ -85,8 +89,8 @@ export async function remoteServerCertificateExists(connection: IBMi, legacy = f
8589
* Generate all certifcates on the server
8690
*/
8791
export async function setup(connection: IBMi) {
88-
const host = connection.currentHost;
89-
const extFileContent = await getExtFileContent(host, connection);
92+
const pw = getPasswordForHost(connection);
93+
const extFileContent = await getExtFileContent(pw, connection);
9094

9195
if (!connection.usingBash()) {
9296
if (connection.remoteFeatures[`bash`]) {
@@ -98,9 +102,9 @@ export async function setup(connection: IBMi) {
98102

99103
const commands = [
100104
`openssl genrsa -out debug_service.key 2048`,
101-
`openssl req -new -key debug_service.key -out debug_service.csr -subj '/CN=${host}'`,
105+
`openssl req -new -key debug_service.key -out debug_service.csr -subj '/CN=${pw}'`,
102106
`openssl x509 -req -in debug_service.csr -signkey debug_service.key -out debug_service.crt -days 1095 -sha256 -req -extfile <(printf "${extFileContent}")`,
103-
`openssl pkcs12 -export -out debug_service.pfx -inkey debug_service.key -in debug_service.crt -password pass:${host}`,
107+
`openssl pkcs12 -export -out debug_service.pfx -inkey debug_service.key -in debug_service.crt -password pass:${pw}`,
104108
`rm debug_service.key debug_service.csr debug_service.crt`,
105109
`chmod 444 debug_service.pfx`
106110
];
@@ -127,9 +131,10 @@ export async function setup(connection: IBMi) {
127131

128132
export async function downloadClientCert(connection: IBMi) {
129133
const localPath = getLocalCertPath(connection);
134+
const keyPass = getPasswordForHost(connection);
130135

131136
const result = await connection.sendCommand({
132-
command: `openssl s_client -connect localhost:${connection.config?.debugPort} -showcerts < /dev/null 2> /dev/null | openssl x509 -outform PEM`,
137+
command: `openssl pkcs12 -in ${getRemoteServerCertificatePath(connection)} -passin pass:${keyPass} -info -nokeys -clcerts 2>/dev/null | openssl x509 -outform PEM`,
133138
directory: getRemoteCertificateDirectory(connection)
134139
});
135140

0 commit comments

Comments
 (0)