【发布时间】:2020-09-28 06:53:52
【问题描述】:
我有以下 curl 命令来授予用户(本地)权限:
curl "https://10.10.135.35/9880/grant_permission?user=username&role=role" -k
我想在 js 中使用 fetch 来达到同样的目的。比如:
const fetchAPIPro = (username, role) =>
fetch(`https://10.10.135.35/9880/grant_permission?user=${username}&role=${role}`, {
referrerPolicy: 'unsafe-url',
credentials: 'omit',
})
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.blob();
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => {
console.error('There has been a problem with your fetch operation:', error);
});
它返回了NET::ERR_CERT_INVALID。我认为这是因为我创建了 SSL/TSL 认证(自签名)。
有没有办法绕过fetch 或授予域认证?
【问题讨论】:
-
SSL 证书不是绑定到 IP,而是绑定到域。
-
@Keith 来自公共 CA 的 SSL 证书绑定到 DNS 地址,但 SSL 证书本身可以包含 IP 地址:security.stackexchange.com/questions/160787/…
标签: javascript reactjs ssl ssl-certificate