我有一个电子应用程序可以与我在拥有自签名证书的https:XXX.XX.XX.XXX:端口上拥有的服务器同步。我怎样才能相信我的电子应用程序的证书?如何信任电子应用程序中的自签名证书?
现在我得到:
Failed to load resource: net::ERR_INSECURE_RESPONSE
我有一个电子应用程序可以与我在拥有自签名证书的https:XXX.XX.XX.XXX:端口上拥有的服务器同步。我怎样才能相信我的电子应用程序的证书?如何信任电子应用程序中的自签名证书?
现在我得到:
Failed to load resource: net::ERR_INSECURE_RESPONSE
订阅由app
模块发出的certificate-error
事件,并确认在事件处理程序的自签名的证书。
你需要把下面的代码放到你的“壳”(核心电子INIT)文件:
// SSL/TSL: this is the self signed certificate support
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
// On certificate error we disable default behaviour (stop loading the page)
// and we then say "it is all fine - true" to the callback
event.preventDefault();
callback(true);
});
但是,这允许你喜欢自我不安全(无效)证书签名的一个。
请注意,这不是连接到服务器的安全方式。
欲了解更多,你可以检查文件:https://electron.atom.io/docs/api/app/#event-certificate-error