Skip to content

Commit c01e12d

Browse files
committed
Fix upstream proxy trust of configured CAs
1 parent ef3d208 commit c01e12d

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"mobx-shallow-undo": "^1.0.0",
105105
"mobx-utils": "^5.1.0",
106106
"mockrtc": "^0.3.1",
107-
"mockttp": "^3.13.0",
107+
"mockttp": "^3.15.0",
108108
"monaco-editor": "^0.27.0",
109109
"node-forge": "^1.3.0",
110110
"openapi-directory": "^1.3.0",

src/model/rules/rules-store.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class RulesStore {
293293
get activePassthroughOptions(): requestHandlers.PassThroughHandlerOptions {
294294
const options: requestHandlers.PassThroughHandlerOptions = { // Check the type to catch changes
295295
ignoreHostHttpsErrors: this.whitelistedCertificateHosts,
296-
trustAdditionalCAs: this.additionalCaCertificates.map((cert) => ({ cert: cert.rawPEM })),
296+
additionalTrustedCAs: this.additionalCaCertificates.map((cert) => ({ cert: cert.rawPEM })),
297297
clientCertificateHostMap: _.mapValues(this.clientCertificateHostMap, (cert) => ({
298298
pfx: Buffer.from(cert.pfx),
299299
passphrase: cert.passphrase
@@ -332,7 +332,10 @@ export class RulesStore {
332332
// Localhost proxy config is ignored
333333
return 'ignored';
334334
} else {
335-
return systemProxyConfig;
335+
return {
336+
...systemProxyConfig,
337+
additionalTrustedCAs: this.additionalCaCertificates.map((cert) => ({ cert: cert.rawPEM }))
338+
};
336339
}
337340
} catch (e) {
338341
console.log("Could not parse proxy", proxyUrl);
@@ -353,7 +356,8 @@ export class RulesStore {
353356
} else {
354357
return {
355358
proxyUrl: `${this.upstreamProxyType}://${this.upstreamProxyHost!}`,
356-
noProxy: this.upstreamNoProxyHosts
359+
noProxy: this.upstreamNoProxyHosts,
360+
additionalTrustedCAs: this.additionalCaCertificates.map((cert) => ({ cert: cert.rawPEM }))
357361
};
358362
}
359363
}

src/model/send/send-request-model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export interface RequestDefinition {
139139

140140
export interface RequestOptions {
141141
ignoreHostHttpsErrors?: string[] | boolean;
142+
additionalTrustedCAs?: Array<{ cert: string }>;
143+
/** @deprecated alias for additionalTrustedCAs */
142144
trustAdditionalCAs?: Array<{ cert: string }>;
143145
clientCertificate?: { pfx: Buffer, passphrase?: string };
144146
proxyConfig?: ClientProxyConfig;

src/model/send/send-store.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,14 @@ export class SendStore {
160160
passthroughOptions.clientCertificateHostMap?.[url.hostname!] ||
161161
undefined;
162162

163+
const additionalCACerts = this.rulesStore.additionalCaCertificates.map((cert) =>
164+
({ cert: cert.rawPEM })
165+
);
166+
163167
const requestOptions = {
164168
ignoreHostHttpsErrors: passthroughOptions.ignoreHostHttpsErrors,
165-
trustAdditionalCAs: this.rulesStore.additionalCaCertificates.map((cert) =>
166-
({ cert: cert.rawPEM })
167-
),
169+
additionalCACerts: additionalCACerts,
170+
trustAdditionalCAs: additionalCACerts, // Deprecated alias, here for backward compat
168171
clientCertificate,
169172
proxyConfig: getProxyConfig(this.rulesStore.proxyConfig),
170173
lookupOptions: passthroughOptions.lookupOptions

0 commit comments

Comments
 (0)