title: How do I trust a self signed certificate from an electron app from the main process, using the `electron.net` API?
body: <p>The goal is to customise certificate validation from within the main process of an electron app, for the use with self-signed certificates and non-matching hostnames in development and testing conditions. The <a href="https://electronjs.org/docs/api/net" rel="nofollow noreferrer"><code>electron.net</code></a> API provides the option to supply a <a href="https://electronjs.org/docs/api/session" rel="nofollow noreferrer"><code>Session</code></a> object, which has a <a href="https://electronjs.org/docs/api/session#sessetcertificateverifyprocproc" rel="nofollow noreferrer"><code>setCertificateVerifyProc</code></a> method. However, the callback I register using that method never gets called.</p>
  
  <p>There is a related question here: <a href="https://stackoverflow.com/questions/38986692/how-do-i-trust-a-self-signed-certificate-from-an-electron-app">How do I trust a self signed certificate from an electron app?</a>
  However, the accepted answer from that question only works in a render process. Indeed, on the main process, the event <code>certificate-error</code> is never issued.</p>