electron certificates network

你。 提交于 2019-12-12 04:24:24

问题


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

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');
...

The result is the same error.

Questions:

  • I am correct in assuming this options is supposed to help here?
  • If so, any ideas what I am doing wrong?

Electron version: 1.2.8

Thanks!


回答1:


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);
  }
});

That you going do the fetch to your api with https.



来源:https://stackoverflow.com/questions/38676209/electron-certificates-network

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!