Skip to content

Commit 6c13c56

Browse files
fix(mbe): use appropriate config for ebe client
Ticket: WP-4622
1 parent dc238cc commit 6c13c56

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/__tests__/routes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Routes', () => {
1212

1313
describe('Health Check Routes', () => {
1414
it('should return 200 and status message for /ping', async () => {
15-
const response = await request(app).get('/ping');
15+
const response = await request(app).post('/ping');
1616
expect(response.status).toBe(200);
1717
expect(response.body).toHaveProperty('status', 'enclaved express server is ok!');
1818
expect(response.body).toHaveProperty('timestamp');

src/masterBitgoExpress/enclavedExpressClient.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as superagent from 'superagent';
22
import debug from 'debug';
33
import { config } from '../config';
44
import { isMasterExpressConfig } from '../types';
5+
import https from 'https';
56

67
const debugLogger = debug('bitgo:express:enclavedExpressClient');
78

@@ -25,6 +26,7 @@ export class EnclavedExpressClient {
2526
private readonly url: string;
2627
private readonly sslCert: string;
2728
private readonly coin?: string;
29+
private readonly enableSSL: boolean;
2830

2931
constructor(coin?: string) {
3032
const cfg = config();
@@ -41,6 +43,7 @@ export class EnclavedExpressClient {
4143
this.url = cfg.enclavedExpressUrl;
4244
this.sslCert = cfg.enclavedExpressSSLCert;
4345
this.coin = coin;
46+
this.enableSSL = !!cfg.enableSSL;
4447
debugLogger('EnclavedExpressClient initialized with URL: %s', this.url);
4548
}
4649

@@ -69,6 +72,12 @@ export class EnclavedExpressClient {
6972
const { body: keychain } = await superagent
7073
.post(`${this.url}/api/${this.coin}/key/independent`)
7174
.ca(this.sslCert)
75+
.agent(
76+
new https.Agent({
77+
rejectUnauthorized: this.enableSSL,
78+
ca: this.sslCert,
79+
}),
80+
)
7281
.type('json')
7382
.send(params);
7483
return keychain;

src/masterExpressApp.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
readCertificates,
2424
setupHealthCheckRoutes,
2525
} from './shared/appUtils';
26-
import { ApiResponseError } from './errors';
2726
import bodyParser from 'body-parser';
2827
import { ProxyAgent } from 'proxy-agent';
2928
import { promiseWrapper } from './routes';

0 commit comments

Comments
 (0)