So I'm trying to make a call inside my node test (AVA) that uses proxy and TLS authorization. I'm using:
- typescript: 3.9.3
- ts-node: 8.10.2
- axios: 0.21.1
- https-proxy-agent: 5.0.0
What I've learnt so far:
AxiosProxyConfig
is broken at the moment so I cannot use it: Axios proxy is not working,https-proxy-agent
is indeed working as it was said by kraiz in bug thread, but... I cannot see anything aboutca
,cert
andkey
I cannot provide those I was not able to find any docs except this one https-proxy-agent npm page.
So just to wrap up with some code, that's what I'm trying to do and I have no idea how to achieve that:
const httpsProxyAgent = new HttpsProxyAgent({
cert: this.cert,
key: this.key,
ca: this.ca,
host: PROXY_HOST,
port: PROXY_PORT,
});
// then later
const config: AxiosRequestConfig = {
httpsAgent: httpsProxyAgent,
headers: { ... }
proxy: false
};
Though HttpsProxyAgent
seems to extend Agent
those options (certs part) are not used and I get UNABLE_TO_VERIFY_LEAF_SIGNATURE
error that indicates that ca
is ignored.
Does anyone knows how to provide those certs to this agent?
I couldn't find any answers. I'm not a node expert so I might have missed something obvious.
Thanks in advance!
PS. I've also tried Objects.assign()
like this
// this proxy agent is working for sure (tested)
const httpsProxyAgent = new HttpsProxyAgent('http://proxy:1234');
// trying to assign certs after creating httpsProxyAgent
Object.assign(httpsAgent.options, {
ca: this.ca,
key: this.key,
cert: this.cert
});
// then again passing it to AxiosRequestConfig.httpAgent and making a call
result was once again UNABLE_TO_VERIFY_LEAF_SIGNATURE
.
PSS. I've seen this better-https-proxy-agent
(git page) that seems to have solution, the only drawback is I cannot see any TS support.
You can add the certificates in the agent, and the proxy in the request call, something like this...