From ae3cf104b796a35d31d95c1c68e248b82c22a2bd Mon Sep 17 00:00:00 2001 From: Jan T Date: Mon, 29 Jan 2024 09:49:50 +0100 Subject: [PATCH] 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. --- .env.sample | 1 + lib/api/archiveHandler.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index d2a8d60..ad56075 100644 --- a/.env.sample +++ b/.env.sample @@ -20,6 +20,7 @@ MAX_LINKS_PER_USER= ARCHIVE_TAKE_COUNT= BROWSER_TIMEOUT= IGNORE_UNAUTHORIZED_CA= +IGNORE_HTTPS_ERRORS= # AWS S3 Settings SPACES_KEY= diff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.ts index 60ea790..88ff97e 100644 --- a/lib/api/archiveHandler.ts +++ b/lib/api/archiveHandler.ts @@ -21,7 +21,11 @@ const BROWSER_TIMEOUT = Number(process.env.BROWSER_TIMEOUT) || 5; export default async function archiveHandler(link: LinksAndCollectionAndOwner) { 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 timeoutPromise = new Promise((_, reject) => {