A sample shows client-certificate
usage in Electron. In this sample, we launch
a https server, and create our own Server/Client Certificates with a local CA.
-
Generate all the required PEM formate files by running
./ssl/setup.sh
script. One the script is done, all the generated files are underssl/
folder. -
Import
rootCA.crt
andclient.p12
to your system. -
Run
node server.js
to launch a https serverhttps://localhost:5000
. -
Run the app in electron, and you will view a
approved
in the webpage.
If you visit https://localhost:5000
in Chrome, the Chrome browser will prompt up
a window to let users to select the CA certificates, which is a default browser behavior.
Unlike browser, Electron will use the first matched certificate by default.
The --client-certificate
switch command doesn't work if there are no matched certificates
in OS, the bug is tracked in atom/electron#1956.
And the switch only supports no-password protected PEM format file. In this sample,
the file is client.crt
.