[英]Local Execution Google: https request failed
Ensure security in my request message.确保我的请求消息中的安全性。
https : natively implemented in node, it seems https : 在 node 中本地实现,似乎
node : 12.15.0节点:12.15.0
I get a "Failed to fetch" error when I do get request on an api served with https and self certified certificate.当我在使用 https 和自认证证书提供的 api 上收到请求时,我收到“无法获取”错误。
What I tried:我试过的:
1 - http request: it works fine on google home device and my local machine, 1 - http 请求:它在 google home 设备和我的本地机器上工作正常,
2 - https request: it works on my local machine but not on google home device. 2 - https 请求:它适用于我的本地机器,但不适用于 google home 设备。
Code I use:我使用的代码:
import fetch from 'node-fetch';
import env from './configFile';
import https, { Agent } from 'https';
export default function get(): Promise<any> {
const url = "https://api.url";
const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});
const option = {
method: 'get',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(env.login! + ':' + env.password!),
},
agent: httpsAgent,
};
return fetch(url, option)
.then(res => {
return res.json();
})
.catch(error => {
throw new Error(error);
});
}
Here I disable ssl certification verification.这里我禁用ssl认证验证。 It is something i'll change later because it is not secure, but at least i want to do an https request without error.
这是我稍后会更改的内容,因为它不安全,但至少我想做一个 https 请求而不会出错。
Go to this link: errors转到此链接: 错误
I made a full tutorial, if you want to reproduce the error: https://github.com/killvi/localExecutionHttpsError我做了一个完整的教程,如果你想重现错误: https : //github.com/killvi/localExecutionHttpsError
In this tuto, i try to make an https request on google to check if I can do it without error.在本教程中,我尝试在 google 上发出 https 请求,以检查我是否可以做到没有错误。 So is not exactly same implementation as mine.
所以与我的实现并不完全相同。 But if it works with google, at least i will known that my problem does not come from https implementation in google home device.
但如果它适用于谷歌,至少我会知道我的问题不是来自谷歌家庭设备中的 https 实现。
Google answered my question:谷歌回答了我的问题:
Currently, local execution apps can only use unencrypted HTTP/TCP/UDP to communicate locally to their devices.
目前,本地执行应用程序只能使用未加密的 HTTP/TCP/UDP 与其设备进行本地通信。 It has been requested that we enable TLS capabilities over the local channel to enable HTTPS and other standard encrypted transport methods.
已要求我们通过本地通道启用 TLS 功能,以启用 HTTPS 和其他标准加密传输方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.