Playwright Python: NS_ERROR_UNKNOWN when launching Firefox with firefox_user_prefs and security.enterprise_roots.enabled

I’m trying to use playwright in Python to scrape a portal in my company internal network, and I’m getting a useless error message (NS_ERROR_UNKNOWN) when I try to set some preferences in Firefox (according to playwrights documentation)

I’m using Ubuntu 22.04.4 LTS with WSL and Python 3.10.12. The portal only works properly in Firefox, and is only served through HTTPS. The company MITMs all SSL connections (including connections to the internal network), but I have the company root CA installed in WSL.

Here’s a sample code:

from playwright.sync_api import sync_playwright

with sync_playwright() as pwobj:
    browser = pwobj.firefox.launch(
        headless = False,
        firefox_user_prefs = {
            "security.enterprise_roots.enabled": "true"
        }
    )

    # page with untrusted certificate for testing purposes
    page = browser.new_page().goto("https://untrusted-root.badssl.com/")

When I run this code, I get the following error message:

Traceback (most recent call last):
  File "/home/lmnice/sw/projects/mapebot/Rascunhos/playwright_error.py", line 4, in <module>
    browser = pwobj.firefox.launch(
  File "/home/lmnice/.venvs/mapebot/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 13991, in launch
    self._sync(
  File "/home/lmnice/.venvs/mapebot/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
    return task.result()
  File "/home/lmnice/.venvs/mapebot/lib/python3.10/site-packages/playwright/_impl/_browser_type.py", line 94, in launch
    Browser, from_channel(await self._channel.send("launch", params))
  File "/home/lmnice/.venvs/mapebot/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 59, in send
    return await self._connection.wrap_api_call(
  File "/home/lmnice/.venvs/mapebot/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 514, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: BrowserType.launch: Protocol error (Browser.enable): Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.setStringPref]
Call log:
<launching> /home/lmnice/.cache/ms-playwright/firefox-1449/firefox/firefox -no-remote -wait-for-browser -foreground -profile /tmp/playwright_firefoxdev_profile-XXXXXXFpc6uf -juggler-pipe -silent
  - <launched> pid=24470
  - [pid=24470][err] JavaScript warning: resource://services-settings/Utils.sys.mjs, line 114: unreachable code after return statement
  - [pid=24470][out] console.warn: services.settings: Ignoring preference override of remote settings server
  - [pid=24470][out] console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
  - [pid=24470][out] console.error: ({})
  - [pid=24470][out] 
  - [pid=24470][out] Juggler listening to the pipe
  - [pid=24470][out] console.error: "Warning: unrecognized command line flag" "-wait-for-browser"
  - [pid=24470][out] 
  - [pid=24470][out]         ERROR: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.setStringPref] Browser.enable@chrome://juggler/content/protocol/BrowserHandler.js:40:24
  - [pid=24470][out]

If I run the same code without the firefox_user_prefs setting, I get the following error mesage:

Traceback (most recent call last):
  File "/home/lmnice/sw/projects/mapebot/Rascunhos/playwright_error.py", line 15, in <module>
    page = browser.new_page().goto("https://untrusted-root.badssl.com/")
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 8686, in goto
    self._sync(
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
    return task.result()
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/_impl/_page.py", line 519, in goto
    return await self._main_frame.goto(**locals_to_params(locals()))
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/_impl/_frame.py", line 145, in goto
    await self._channel.send("goto", locals_to_params(locals()))
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 59, in send
    return await self._connection.wrap_api_call(
  File "/home/lmnice/.venvs/error_playwright/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 514, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: Page.goto: SEC_ERROR_UNKNOWN_ISSUER
Call log:
navigating to "https://untrusted-root.badssl.com/", waiting until "load"

I get the same error message as immediately above (SEC_ERROR_UNKOWN_ISSUER) if I run the code with some other random Firefox setting, say:

from playwright.sync_api import sync_playwright

with sync_playwright() as pwobj:
    browser = pwobj.firefox.launch(
        headless = False,
        firefox_user_prefs = {
            # random option just to check if other options also cause this error
            "browser.backspace_action": 0
        }
    )

    # page with broken certificate for testing purposes
    page = browser.new_page().goto("https://untrusted-root.badssl.com/")

The error appears to stem from the specific setting security.enterprise_roots.enabled, but other than that I’m stymied.

I would greatly appreciate it if someone would help me getting the playwright version of Firefox to work with custom CAs.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật