[英]Electron doesnt execute https call to local spring server, curl works
I'm simply trying to connect to a local Spring configured with SSL / TLS 1.2.我只是想连接到配置了 SSL / TLS 1.2 的本地 Spring。
Context (Server): Server is built with Spring, logs when creating a request via curl.上下文(服务器):服务器使用 Spring 构建,通过 curl 创建请求时记录。 Also requires a certificate from the client (X.509 certificate based authentication)
还需要来自客户端的证书(基于 X.509 证书的身份验证)
Client (CURL, command-line): Works fine!客户端(CURL,命令行):工作正常!
Client (Electron): When the code below gets executed nothing happens.客户端(电子):当下面的代码被执行时,什么也没有发生。 No requests are being made to the spring (nothing logs), nor is any error occuring.
没有向 spring 发出请求(没有日志),也没有发生任何错误。 Nothing.
没有什么。 Electron is such a drag to debug..
Electron 就是这样拖着调试..
Code:代码:
let options = {
hostname: 'localhost',
port: 8443,
path: '/',
cert: fs.readFileSync(global.relativePaths.config + 'client.crt'),
key: fs.readFileSync(global.relativePaths.config + 'clientprivate.key'),
passphrase: '[phrase_here]',
rejectUnauthorized: false,
requestCert: true
};
let request = https.request(options);
request.on('error', () => {
console.log("Error!");
})
Also, this is just localhost, hence the rejectUnauthorized - I'm working with self-signed certificates until ready for production.此外,这只是本地主机,因此拒绝未授权 - 我正在使用自签名证书,直到准备好生产。 :)
:)
Thank you in advance.先感谢您。 :)
:)
EDIT: using the test-code on the wiki (call to github) outputs with no problem.. what could it be?... also, im doing this on the main process (not on the renderer)编辑:使用wiki上的测试代码(调用github)输出没有问题..它可能是什么?...另外,我在主进程(而不是渲染器)上这样做
Try using the http-client
library like [axios][1]
.尝试使用
http-client
库,如[axios][1]
。 axios is a promise-based HTTP client for the browser and node.js. axios 是基于 Promise 的 HTTP 客户端,适用于浏览器和 node.js。 It worths giving a try to most used libraries like axios, it's simple to use.
值得一试最常用的库,如 axios,它使用简单。 If the issue still persists, try setting the
User-Agent
header in your request.如果问题仍然存在,请尝试在您的请求中设置
User-Agent
header。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.