@@ -10,7 +10,6 @@ import * as https from 'https';
10
10
import type * as Mockttp from 'mockttp' ;
11
11
import {
12
12
getDnsLookupFunction ,
13
- shouldUseStrictHttps ,
14
13
getUpstreamTlsOptions as getUpstreamMockttpTlsOptions
15
14
} from 'mockttp/dist/rules/passthrough-handling' ;
16
15
import { getAgent } from 'mockttp/dist/rules/http-agents' ;
@@ -58,15 +57,6 @@ export class HttpClient {
58
57
JSON . stringify ( dnsServers )
59
58
) ;
60
59
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
-
70
60
async sendRequest (
71
61
requestDefn : RequestDefinition ,
72
62
options : RequestOptions
@@ -78,16 +68,7 @@ export class HttpClient {
78
68
// here, since the UI controls the passthrough options directly already.
79
69
80
70
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 ;
91
72
92
73
const agent = await getAgent ( {
93
74
protocol : url . protocol as 'http:' | 'https:' ,
@@ -107,9 +88,18 @@ export class HttpClient {
107
88
lookup : this . getDns ( options . lookupOptions ?. servers ) ,
108
89
109
90
// 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
+ } )
113
103
} ) ;
114
104
115
105
options . abortSignal ?. addEventListener ( 'abort' , ( ) => {
0 commit comments