Skip to content

Instantly share code, notes, and snippets.

@panther7
Created August 12, 2025 09:50
Show Gist options
  • Select an option

  • Save panther7/f0f9ec0da799c33bc6725860717b3323 to your computer and use it in GitHub Desktop.

Select an option

Save panther7/f0f9ec0da799c33bc6725860717b3323 to your computer and use it in GitHub Desktop.
print certificate updates
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
<br>
UserAgent: <div id="ua"></div>
<!-- You can also require other files to run in this process -->
<script src="./renderer.js"></script>
</body>
</html>
const {
app,
session,
BrowserWindow,
WebContentsView,
} = require('electron')
const path = require('node:path');
const testPartition = 'persist:test';
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
}
function createTab() {
const tab = new WebContentsView({
webPreferences: {
partition: testPartition,
},
})
tab.webContents.navigationHistory.restore({
entries: [
{
url: 'https://www.diit.cz',
title: 'Diit',
}
],
index: 0
})
}
app.whenReady().then(() => {
const ses = session.fromPartition(testPartition)
ses.setCertificateVerifyProc((cer) => console.log(cer.hostname))
createWindow()
createTab()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
{
"name": "elated-neck-bat-ftagd",
"productName": "elated-neck-bat-ftagd",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "filip.mosner",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "100.0.0"
}
}
/**
* The preload script runs before `index.html` is loaded
* in the renderer. It has access to web APIs as well as
* Electron's renderer process modules and some polyfilled
* Node.js functions.
*
* https://www.electronjs.org/docs/latest/tutorial/sandbox
*/
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
document.getElementById('ua').textContent = navigator.userAgent
})
/**
* This file is loaded via the <script> tag in the index.html file and will
* be executed in the renderer process for that window. No Node.js APIs are
* available in this process because `nodeIntegration` is turned off and
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment