x509: certificate signed by unknown authority on selenium and seleniumwire
Hi, I'm trying to use zyte proxy with selenium and seleniumwire (tried with Firefox and Chrome) but I still have this issue :
INFO[0474] Finish request client_id=d62e32ddf5e1c27f6b222b85b25789f46478ca61 error="cannot execute a request: cannot dial to the netloc: cannot upgrade connection to tls: cannot perform TLS handshake: x509: certificate signed by unknown authority" method=POST remote_addr="127.0.0.1:54179" request_id=eac52093-cc46-496b-9fa2-d876f5f3c6d6 response_code=200 url="https://accounts.google.com/ListAccounts?gpsia=1&source=ChromiumBrowser&json=standard"
which seems to be linked to cannot perform TLS handshake: x509: certificate signed by unknown authority
for every https urls.
Here is my code :
import time
from seleniumwire import webdriver
options = {
'mitm_http2': False,
'proxy': {
'http': 'http://localhost:3128',
'https': 'https://localhost:3128',
}
}
SELENIUM_DRIVER_ARGUMENTS = [
# "--headless",
"log-level=3",
"--no-sandbox",
"start-maximized",
"enable-automation",
"--disable-infobars",
"--disable-xss-auditor",
"--disable-setuid-sandbox",
"--disable-xss-auditor",
"--disable-web-security",
"--disable-dev-shm-usage",
"--disable-webgl",
"--disable-popup-blocking",
"ignore-certificate-errors",
]
chrome_options = webdriver.ChromeOptions()
for argument in SELENIUM_DRIVER_ARGUMENTS:
chrome_options.add_argument(argument)
driver = webdriver.Chrome(
options=chrome_options,
seleniumwire_options=options
)
driver.get("https://nordvpn.com/what-is-my-ip/")
time.sleep(10)
driver.close()
and here is my configuration
adblockparser==0.7
amqp==5.1.0
asgiref==3.5.0
async-generator==1.10
async-timeout==4.0.2
attrs==21.4.0
backports.zoneinfo==0.2.1
billiard==3.6.4.0
blinker==1.4
Brotli==1.0.9
celery==5.2.6
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
click==8.1.2
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
coloredlogs==15.0.1
cryptography==36.0.2
Deprecated==1.2.13
Django==4.0.3
django-cors-headers==3.11.0
djangorestframework==3.13.1
filelock==3.6.0
flower==1.0.0
h11==0.13.0
h2==4.1.0
hpack==4.0.0
humanfriendly==10.0
humanize==4.0.0
hyperframe==6.0.1
idna==3.3
img2pdf==0.4.4
importlib-resources==5.8.0
kaitaistruct==0.10
kombu==5.2.4
lxml==4.8.0
ocrmypdf==13.5.0
outcome==1.1.0
packaging==21.3
pdfminer==20191125
pdfminer.six==20220524
pdftotext==2.2.2
pikepdf==5.1.5
Pillow==9.1.1
pluggy==1.0.0
prometheus-client==0.14.0
prompt-toolkit==3.0.29
pyasn1==0.4.8
pycparser==2.21
pycryptodome==3.14.1
pyOpenSSL==22.0.0
pyparsing==3.0.7
PySocks==1.7.1
pytz==2022.1
random-user-agent==1.0.1
redis==4.2.2
reportlab==3.6.10
requests==2.27.1
requests-file==1.5.1
selenium==4.3.0
selenium-wire==4.6.5
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
sqlparse==0.4.2
tldextract==3.2.0
tornado==6.1
tqdm==4.64.0
trio==0.20.0
trio-websocket==0.9.2
urllib3==1.26.9
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.0
wsproto==1.1.0
zipp==3.8.0
zstandard==0.18.0
Zyte-SmartProxy-Selenium==1.0.4
Would you have any idea please ? Because I tried with selenium and seleniumwire but still get this error
Thank you very much
And here is my selenium code, also not working
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--ignore-certificate-errors")
#options.add_argument('--headless')
HEADLESS_PROXY = "localhost:3128"
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['acceptInsecureCerts'] = True
caps['proxy'] = {
"httpProxy": HEADLESS_PROXY,
"sslProxy": HEADLESS_PROXY,
"proxyType": "MANUAL",
}
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options, desired_capabilities=caps)
driver.get("http://nordvpn.com/what-is-my-ip/")
time.sleep(10)
driver.close()
Hi, Someone solve this problem? I'm having similar problems too:
<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">{"error":{"code":"executor","message":"cannot execute a request","stack":[{"code":"executor","message":"cannot execute a request","status_code":0},{"code":"","message":"cannot dial to the netloc","status_code":0},{"code":"","message":"cannot upgrade connection to tls","status_code":0},{"code":"tls_handshake","message":"cannot perform TLS handshake","status_code":0},{"code":"","message":"x509: certificate signed by unknown authority","status_code":0}]}} </pre></body></html>
Someone was able to use this proxy with python 3.6 and selenium 3?
Hi,
Have you installed the ca.crt provided in the repository?