Cristian Muscalu
Cristian Muscalu

Reputation: 9905

electron how to allow insecure https

Loading https://github.com works fine for exmaple.
But loading an insecure https, the page displays empty.

I've done some research and tried the 3 flags (webSecurity, allowDisplayingInsecureContent, allowRunningInsecureContent) below with no success.

Looking for any known solutions. Thank you.

const { BrowserWindow } = require('electron').remote;

    let win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            plugins: true,
            nodeIntegration: false,
            webSecurity: false,
            allowDisplayingInsecureContent: true,
            allowRunningInsecureContent: true
        }
    });

    win.loadURL('https://insecure...')

Upvotes: 23

Views: 27744

Answers (2)

Kamran  Gasimov
Kamran Gasimov

Reputation: 1783

100% Solution

Not all other solutions helped except this one

Source: https://www.electronjs.org/docs/latest/api/app#event-certificate-error

const { app } = require('electron')

app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
  
    // Prevent having error
    event.preventDefault()
    // and continue
    callback(true)

})

Upvotes: 5

Paulo Henrique
Paulo Henrique

Reputation: 1028

In main.js, do:

const { app } = require('electron')

app.commandLine.appendSwitch('ignore-certificate-errors')

Upvotes: 60

Related Questions