【发布时间】:2020-02-16 19:37:24
【问题描述】:
我在 ReactJS 中使用 Axios 来调用我的 API,该 API 使用自签名证书托管在云上。请求的错误返回 net::ERR_CERT_REVOKED。
我已将自签名代码添加到我在运行 reactjs 的 MacOS 上的登录钥匙串中。但是当我在 Chrome 的日志中查看错误时,证书仍然被吊销。在 safari 上,错误是 Failed to load resource: The certificate for this server is invalid.
try {
const response = await axios.post(
'https://1.1.1.1:3000/login',
{ withCredentials: true },
{ auth: apiAuth },
{ data: bodyFormData },
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }
)
return response.data;
} catch (error) {
console.log(error);
}
问题的 IP 地址已更改。
我尝试在 Axios 请求中使用以下代码,但没有帮助
const agent = new https.Agent({
rejectUnauthorized: false
});
期望服务器给出响应,但作为响应被撤销证书。
【问题讨论】: