Skip to content

Commit

Permalink
Simplify WS trusted CA code in line with the requests equivalent
Browse files Browse the repository at this point in the history
No functional change here (AFAIK) just reusing the same code for both to
simplify things
  • Loading branch information
pimterry committed Jul 15, 2024
1 parent c35d55d commit 3a64101
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/rules/websockets/websocket-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import {
getUpstreamTlsOptions,
getClientRelativeHostname,
getDnsLookupFunction,
shouldUseStrictHttps
shouldUseStrictHttps,
getTrustedCAs
} from '../passthrough-handling';

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

if (!this._trustedCACertificates) {
this._trustedCACertificates = Promise.all(
(tls.rootCertificates as Array<string | Promise<string>>)
.concat(this.extraCACertificates.map(certObject => {
if ('cert' in certObject) {
return certObject.cert.toString('utf8');
} else {
return fs.readFile(certObject.certPath, 'utf8');
}
}))
);
this._trustedCACertificates = getTrustedCAs(undefined, this.extraCACertificates);
}

return this._trustedCACertificates;
Expand Down

0 comments on commit 3a64101

Please sign in to comment.