电子证书网络 [英] electron certificates network
问题描述
我正在尝试编写一个简单的电子应用程序以与REST服务器连接。服务器没有适当的证书。当我尝试发出 GET请求(使用fetch())时,收到以下错误消息:
I am trying to write a simple electron app to interface with a REST server. The server doesn't have the appropriate certificates. When I try to make a 'GET' request (using fetch()), I get the following error message:
Failed to load resource: net::ERR_BAD_SSL_CLIENT_AUTH_CERT
当前无法修复证书。我尝试使用 ignore-certificates-error标志(请参见下文)。似乎应该让我跳过此错误,但事实并非如此。
Fixing the certs is not currently an option. I tried to use the 'ignore-certificates-error' flag (see below). It seems like it should allow me to skip over this error, but it doesn't.
var electron = require('electron');
var app = electron.app
app.commandLine.appendSwitch('ignore-certificate-errors');
...
结果是相同的错误。
问题:
- 我认为此选项可以帮助我是正确的在这里?
- 如果是这样,有什么想法我做错了吗?
电子版本: 1.2.8
Electron version: 1.2.8
谢谢!
推荐答案
您可以更新版本并使用此回调:
You can update your version of electron and use this callback:
app.on('certificate-error', (event, webContents, link, error, certificate, callback) => {
if ('yourURL/api/'.indexOf(link) !== -1) {
// Verification logic.
event.preventDefault();
callback(true);
} else {
callback(false);
}
});
您要使用https来获取api。
That you going do the fetch to your api with https.
这篇关于电子证书网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!