所以我试图在使用代理和 TLS 授权的节点测试 (AVA) 中进行调用。 我正在使用:
到目前为止我学到了什么:
AxiosProxyConfig
目前已损坏,因此我无法使用它:
Axios proxy is not working,https-proxy-agent
确实像 by kraiz in bug thread 所说的那样工作,但是......我看不到任何关于 ca
、cert
和 key
的信息,我无法提供除了这个 https-proxy-agent npm page 之外,我找不到任何文档。所以只是用一些代码来结束,这就是我想要做的,但我不知道如何实现:
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
};
虽然 HttpsProxyAgent
似乎扩展了 Agent
这些选项(证书部分)没有使用,我收到 UNABLE_TO_VERIFY_LEAF_SIGNATURE
错误,表明 ca
被忽略。
有谁知道如何向该代理提供这些证书?
我找不到任何答案。我不是节点专家,所以我可能错过了一些明显的东西。
提前致谢!
附注。我也试过这样Objects.assign()
// 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
结果又是UNABLE_TO_VERIFY_LEAF_SIGNATURE
。
PSS。我见过这个 better-https-proxy-agent
(git page) 似乎有解决方案,唯一的缺点是我看不到任何 TS 支持。