Skip to content

Commit 4b4488e

Browse files
Merge pull request #137 from gjsjohnmurray/fix-136
Accept self-signed certificates if `http.proxyStrictSSL` is set to `false`
2 parents 04d9f46 + 33d1ac7 commit 4b4488e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/makeRESTRequest.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import axios, { AxiosResponse } from 'axios';
44
import axiosCookieJarSupport from 'axios-cookiejar-support';
55
import tough = require('tough-cookie');
6+
import { workspace } from 'vscode';
67
import { ServerSpec } from './extension';
8+
import * as https from 'https';
79

810
axiosCookieJarSupport(axios);
911

@@ -20,14 +22,17 @@ export interface AtelierRESTEndpoint {
2022

2123
/**
2224
* Make a REST request to an InterSystems server.
23-
*
25+
*
2426
* @param method The REST method.
2527
* @param server The server to send the request to.
2628
* @param endpoint Optional endpoint object. If omitted the request will be to /api/atelier/
2729
* @param data Optional request data. Usually passed for POST requests.
2830
*/
2931
export async function makeRESTRequest(method: "HEAD"|"GET"|"POST", server: ServerSpec, endpoint?: AtelierRESTEndpoint, data?: any): Promise<AxiosResponse | undefined> {
3032

33+
// Create the HTTPS agent
34+
const httpsAgent = new https.Agent({ rejectUnauthorized: workspace.getConfiguration("http").get("proxyStrictSSL") });
35+
3136
// Build the URL
3237
var url = server.webServer.scheme + "://" + server.webServer.host + ":" + String(server.webServer.port);
3338
const pathPrefix = server.webServer.pathPrefix;
@@ -46,6 +51,7 @@ export interface AtelierRESTEndpoint {
4651
// There is a data payload
4752
respdata = await axios.request(
4853
{
54+
httpsAgent,
4955
method: method,
5056
url: encodeURI(url),
5157
data: data,
@@ -64,6 +70,7 @@ export interface AtelierRESTEndpoint {
6470

6571
respdata = await axios.request(
6672
{
73+
httpsAgent,
6774
method: method,
6875
url: encodeURI(url),
6976
data: data,
@@ -84,6 +91,7 @@ export interface AtelierRESTEndpoint {
8491
// No data payload
8592
respdata = await axios.request(
8693
{
94+
httpsAgent,
8795
method: method,
8896
url: encodeURI(url),
8997
withCredentials: true,
@@ -98,6 +106,7 @@ export interface AtelierRESTEndpoint {
98106

99107
respdata = await axios.request(
100108
{
109+
httpsAgent,
101110
method: method,
102111
url: encodeURI(url),
103112
auth: {

0 commit comments

Comments
 (0)