Added environment variable "IGNORE_SSL_ERRORS" to instruct playwright/Chromium to ignore SSL errors; this is useful to support generation of browser screenshots from sources with self-signed certificates or untrusted CAs, but also opens the possibility to index sites with rejected certificates; so it should not be enabled as a default behavior.

This commit is contained in:
Jan T 2024-01-29 09:49:50 +01:00
parent 047e156cfb
commit ae3cf104b7
2 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,7 @@ MAX_LINKS_PER_USER=
ARCHIVE_TAKE_COUNT= ARCHIVE_TAKE_COUNT=
BROWSER_TIMEOUT= BROWSER_TIMEOUT=
IGNORE_UNAUTHORIZED_CA= IGNORE_UNAUTHORIZED_CA=
IGNORE_HTTPS_ERRORS=
# AWS S3 Settings # AWS S3 Settings
SPACES_KEY= SPACES_KEY=

View File

@ -21,7 +21,11 @@ const BROWSER_TIMEOUT = Number(process.env.BROWSER_TIMEOUT) || 5;
export default async function archiveHandler(link: LinksAndCollectionAndOwner) { export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
const browser = await chromium.launch(); const browser = await chromium.launch();
const context = await browser.newContext(devices["Desktop Chrome"]); const context = await browser.newContext({
...devices["Desktop Chrome"],
ignoreHTTPSErrors:
process.env.IGNORE_HTTPS_ERRORS === "true",
});
const page = await context.newPage(); const page = await context.newPage();
const timeoutPromise = new Promise((_, reject) => { const timeoutPromise = new Promise((_, reject) => {