Skip to content

Commit

Permalink
Merge pull request #16 from allen-li1231/dev-kernels
Browse files Browse the repository at this point in the history
Add HTTP Agent Configuration
  • Loading branch information
allen-li1231 authored Jan 3, 2025
2 parents bd7cb23 + f44dd57 commit a81e8c6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
38 changes: 28 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,20 @@
},
"zeppelin.proxy.host": {
"order": 7,
"type": [
"string"
],
"type": "string",
"format": "uri",
"default": null,
"description": "Set proxy host for connection with Zeppelin server."
},
"zeppelin.proxy.port": {
"order": 8,
"type": [
"integer"
],
"type": "integer",
"default": null,
"description": "Set proxy port for connection with Zeppelin server."
},
"zeppelin.proxy.credential.username": {
"order": 9,
"type": [
"string"
],
"type": "string",
"default": null,
"description": "Specifies proxy authentication for connection with Zeppelin server."
},
Expand All @@ -186,11 +180,35 @@
},
"zeppelin.proxy.credential.protocol": {
"order": 11,
"type": "string",
"default": null,
"description": "Specifies the proxy protocol for connection with Zeppelin server."
},
"zeppelin.https.CA-Certification": {
"order": 12,
"type": "string",
"default": null,
"description": "Configure a trustworthy private CA cert file path. A complete cert chain is in .pem or .crt format. You must include all certs in the chain up to the trust root."
},
"zeppelin.https.KeyPath": {
"order": 13,
"type": "string",
"default": null,
"description": "Configure a trustworthy private key path."
},
"zeppelin.https.passphase": {
"order": 14,
"type": [
"string"
],
"default": null,
"description": "Specifies the proxy protocol for connection with Zeppelin server."
"description": "Configure key's corresponding passphase."
},
"zeppelin.https.rejectUnauthorized": {
"order": 15,
"type": "boolean",
"default": true,
"description": "Enable client verification. Note that this is otherwise unsafe when accessing a public endpoint."
}
}
},
Expand Down
25 changes: 25 additions & 0 deletions src/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
ParagraphData,
ParagraphConfig
} from './types';
import * as fs from 'fs';
import * as https from 'https';
import axios, {
AxiosInstance,
AxiosRequestConfig,
Expand Down Expand Up @@ -96,6 +98,29 @@ class BasicService {
);
}

setHttpsAgent(
CAPath: string | undefined,
keyPath: string | undefined,
passphrase: string | undefined,
rejectUnauthorized: boolean = false
) {
const httpsAgent = new https.Agent({
rejectUnauthorized: rejectUnauthorized,
});

if (!!CAPath) {
httpsAgent.options.ca = fs.readFileSync(CAPath);
}
if (!!keyPath) {
httpsAgent.options.key = fs.readFileSync(keyPath);
}
if (!!passphrase) {
httpsAgent.options.passphrase = passphrase;
}

this.session.defaults.httpsAgent = httpsAgent;
}

resetCancelToken() {
this.cancelTokenSource = axios.CancelToken.source();
this.session.defaults.cancelToken = this.cancelTokenSource.token;
Expand Down
6 changes: 6 additions & 0 deletions src/extension/notebookKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ export class ZeppelinKernel {

let service = new NotebookService(baseURL, userAgent, getProxy());

let config = vscode.workspace.getConfiguration('zeppelin');
let caPath: string | undefined = config.get('https.CA-Certification');
let keyPath: string | undefined = config.get('https.KeyPath');
let passphase: string | undefined = config.get('https.passphase');
service.setHttpsAgent(caPath, keyPath, passphase);

this._service = service;
return service;
}
Expand Down

0 comments on commit a81e8c6

Please sign in to comment.