@@ -10,7 +10,6 @@ import * as https from 'https';
1010import type * as Mockttp from 'mockttp' ;
1111import {
1212 getDnsLookupFunction ,
13- shouldUseStrictHttps ,
1413 getUpstreamTlsOptions as getUpstreamMockttpTlsOptions
1514} from 'mockttp/dist/rules/passthrough-handling' ;
1615import { getAgent } from 'mockttp/dist/rules/http-agents' ;
@@ -58,15 +57,6 @@ export class HttpClient {
5857 JSON . stringify ( dnsServers )
5958 ) ;
6059
61- getCaConfig ( additionalCAs ?: Array < { cert : string } > ) {
62- if ( ! additionalCAs ) return { } ;
63- else return {
64- ca : tls . rootCertificates . concat (
65- additionalCAs . map ( ( { cert } ) => cert )
66- )
67- } ;
68- }
69-
7060 async sendRequest (
7161 requestDefn : RequestDefinition ,
7262 options : RequestOptions
@@ -78,16 +68,7 @@ export class HttpClient {
7868 // here, since the UI controls the passthrough options directly already.
7969
8070 const effectivePort = getEffectivePort ( url ) ;
81-
82- const strictHttpsChecks = shouldUseStrictHttps (
83- url . hostname ! ,
84- effectivePort ,
85- options . ignoreHostHttpsErrors ?? [ ]
86- ) ;
87- const caConfig = this . getCaConfig (
88- options . additionalTrustedCAs ||
89- options . trustAdditionalCAs
90- ) ;
71+ const additionalCAs = options . additionalTrustedCAs || options . trustAdditionalCAs ;
9172
9273 const agent = await getAgent ( {
9374 protocol : url . protocol as 'http:' | 'https:' ,
@@ -107,9 +88,18 @@ export class HttpClient {
10788 lookup : this . getDns ( options . lookupOptions ?. servers ) ,
10889
10990 // TLS options (should be effectively identical to Mockttp's passthrough config)
110- ...getUpstreamMockttpTlsOptions ( strictHttpsChecks ) ,
111- ...caConfig ,
112- ...options . clientCertificate
91+ ...getUpstreamMockttpTlsOptions ( {
92+ hostname : url . hostname ! ,
93+ port : effectivePort ,
94+
95+ ignoreHostHttpsErrors : options . ignoreHostHttpsErrors ?? [ ] ,
96+ clientCertificateHostMap : options . clientCertificate
97+ ? { '*' : options . clientCertificate }
98+ : { } ,
99+ trustedCAs : additionalCAs
100+ ? tls . rootCertificates . concat ( additionalCAs . map ( ( { cert } ) => cert ) )
101+ : undefined
102+ } )
113103 } ) ;
114104
115105 options . abortSignal ?. addEventListener ( 'abort' , ( ) => {
0 commit comments