Reputation: 81
My company cert lives in C:
Python Selenium scripts are configured to plug into SauceLabs account and run webdriver
# Point Python's certificate handling to certificate
os.environ['SSL_CERT_FILE'] = 'C:\\Users\\test\\.certificates\\CA.pem'
# Setting up Sauce Labs capabilities
sauce_options = {
"username": "ProdTest",
"accessKey": "xxxx",
"appiumVersion": "2.1.3",
"build": "test1",
"name": "Health Test - Windows 11"
}
chrome_options = ChromeOptions()
chrome_options.set_capability('browserVersion', 'latest')
chrome_options.set_capability('platformName', 'Windows 11')
chrome_options.set_capability('sauce:options', sauce_options)
# URL for Sauce Labs
url = "https://ondemand.us-west-1.saucelabs.com/wd/hub"
# Initialize the remote WebDriver
driver = webdriver.Remote(command_executor=url, options=chrome_options)
I repeatedly get SSL Cert errors
File "C:\Users\test\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\retry.py", line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ondemand.us-west-1.saucelabs.com', port=443): Max retries exceeded with url: /wd/hub/session (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')))
I can connect to it fine like so from our work network.
import ssl
import urllib.request as request
# Point to cert
ssl_context = ssl.create_default_context(cafile='C:\\Users\\test\\.certificates\\CA.pem')
try:
with request.urlopen('https://ondemand.us-west-1.saucelabs.com', context=ssl_context) as response:
print('SSL Connection Successful:', response.read())
except Exception as e:
print('SSL Connection Failed:', e)
Any ideas?
Upvotes: 0
Views: 44