Skip to content

Commit 3a64101

Browse files
committed
Simplify WS trusted CA code in line with the requests equivalent
No functional change here (AFAIK) just reusing the same code for both to simplify things
1 parent c35d55d commit 3a64101

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/rules/websockets/websocket-handlers.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import {
3838
getUpstreamTlsOptions,
3939
getClientRelativeHostname,
4040
getDnsLookupFunction,
41-
shouldUseStrictHttps
41+
shouldUseStrictHttps,
42+
getTrustedCAs
4243
} from '../passthrough-handling';
4344

4445
import {
@@ -212,16 +213,7 @@ export class PassThroughWebSocketHandler extends PassThroughWebSocketHandlerDefi
212213
if (!this.extraCACertificates.length) return undefined;
213214

214215
if (!this._trustedCACertificates) {
215-
this._trustedCACertificates = Promise.all(
216-
(tls.rootCertificates as Array<string | Promise<string>>)
217-
.concat(this.extraCACertificates.map(certObject => {
218-
if ('cert' in certObject) {
219-
return certObject.cert.toString('utf8');
220-
} else {
221-
return fs.readFile(certObject.certPath, 'utf8');
222-
}
223-
}))
224-
);
216+
this._trustedCACertificates = getTrustedCAs(undefined, this.extraCACertificates);
225217
}
226218

227219
return this._trustedCACertificates;

0 commit comments

Comments
 (0)