jtl*_*sey 16 ssl https self-signed electron
我有一个电子应用程序,它与我拥有的服务器同步,https://XXX.XX.XX.XXX:port具有自签名证书.我怎么能相信我的电子应用程序的证书?
现在我得到:
Failed to load resource: net::ERR_INSECURE_RESPONSE
Run Code Online (Sandbox Code Playgroud)
Pet*_*nar 26
您需要将以下代码放入"shell"(核心电子初始化)文件中:
// 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);
});
Run Code Online (Sandbox Code Playgroud)
但是这允许你自己签名的不安全(无效)证书.
请注意,这不是连接到服务器的安全方式.
有关更多信息,请查看文档:https://electron.atom.io/docs/api/app/#event-certificate-error
小智 6
如果'certificate-error'事件不起作用,请尝试以下操作:
if (process.env.NODE_ENV === 'DEV') {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12027 次 |
| 最近记录: |