Skip to content

Commit 08dcc1a

Browse files
committed
chore: fix loading the certs repetetively
Ticket: WP-00000
1 parent 15ffaea commit 08dcc1a

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

src/api/enclaved/postIndependentKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function postIndependentKey(
1212

1313
// setup clients
1414
const bitgo: BitGo = req.bitgo;
15-
const kms = new KmsClient();
15+
const kms = new KmsClient(req.config);
1616

1717
// create public and private key pairs on BitGo SDK
1818
const coin = bitgo.coin(req.params.coin);

src/api/enclaved/signMultisigTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function signMultisigTransaction(
1919
}
2020

2121
const bitgo = req.bitgo;
22-
const kms = new KmsClient();
22+
const kms = new KmsClient(req.config);
2323

2424
// Retrieve the private key from KMS
2525
let prv: string;

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ function masterExpressEnvConfig(): Partial<MasterExpressConfig> {
214214
throw new Error('ENCLAVED_EXPRESS_URL environment variable is required and cannot be empty');
215215
}
216216

217-
if (!enclavedExpressCert) {
218-
throw new Error('ENCLAVED_EXPRESS_CERT environment variable is required and cannot be empty');
217+
if (tlsMode === TlsMode.MTLS && !enclavedExpressCert) {
218+
throw new Error('ENCLAVED_EXPRESS_CERT environment variable is required for MTLS mode.');
219219
}
220220

221221
// Debug mTLS environment variables

src/kms/kmsClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import debug from 'debug';
22
import * as superagent from 'superagent';
3-
import { config, isMasterExpressConfig } from '../config';
3+
import { EnclavedConfig, isMasterExpressConfig } from '../config';
44
import { PostKeyKmsSchema, PostKeyParams, PostKeyResponse } from './types/postKey';
55
import { GetKeyKmsSchema, GetKeyParams, GetKeyResponse } from './types/getKey';
66

@@ -9,8 +9,7 @@ const debugLogger = debug('bitgo:express:kmsClient');
99
export class KmsClient {
1010
private readonly url: string;
1111

12-
constructor() {
13-
const cfg = config();
12+
constructor(cfg: EnclavedConfig) {
1413
if (isMasterExpressConfig(cfg)) {
1514
throw new Error('Configuration is not in enclaved express mode');
1615
}

0 commit comments

Comments
 (0)