How to Import Self-Signed certificate into headless-Firefox

66 Views Asked by At

Question

I want to access some websites using selenium(Python) and headless-firefox with Self-Signed certificate.

When I use FireFox Browser instead of selenium and headless-firefox, I could realize this as the following:

  1. prepare Self-Signed certificate
  2. Import it intor FireFox Browser like this
  3. access websites using imported Self-Signed certificate

I want to do the same thing using headless-firefox and even using selenium(Python), but I have no idea.

Can anyone teach me if this is possible and if so, how?

Additional Information

1

There are 1 best solutions below

0
kkkkgyg On

I solved by myself.

To realize this, we can use policies.json

Create a file named /opt/firefox/distribution/policies.json in the Firefox installation directory (eg. /opt/firefox). The directory depends on OS

// policies.json
{
"policies": {
"Certificates": {
    "ImportEnterpriseRoots": true,
    "Install" [
               "usr/local/share/ca-certificates/your.crt" // path of self-signed certificate
               ]
         }
    }
}