Skip to content

Commit

Permalink
Allow passing rejectUnauthorized to the proxied request
Browse files Browse the repository at this point in the history
  • Loading branch information
thevictorlopez committed Oct 14, 2024
1 parent 5555794 commit 2202e40
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/https-proxy-agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ConnectOpts<T> = {
export type HttpsProxyAgentOptions<T> = ConnectOpts<T> &
http.AgentOptions & {
headers?: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
requestRejectUnauthorized?: boolean;
};

/**
Expand All @@ -47,6 +48,7 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {
readonly proxy: URL;
proxyHeaders: OutgoingHttpHeaders | (() => OutgoingHttpHeaders);
connectOpts: net.TcpNetConnectOpts & tls.ConnectionOptions;
requestRejectUnauthorized: boolean;

constructor(proxy: Uri | URL, opts?: HttpsProxyAgentOptions<Uri>) {
super(opts);
Expand All @@ -72,6 +74,8 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {
host,
port,
};
this.requestRejectUnauthorized =
opts?.requestRejectUnauthorized ?? true;
}

/**
Expand Down Expand Up @@ -149,7 +153,8 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {
const servername = opts.servername || opts.host;
return tls.connect({
...omit(opts, 'host', 'path', 'port'),
socket,
rejectUnauthorized: this.requestRejectUnauthorized,
socket: socket,
servername,
});
}
Expand Down

0 comments on commit 2202e40

Please sign in to comment.