Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChromeDriver ERR_SSL_PROTOCOL_ERROR despite --ignore-certificate-errors

I'm trying to run integration tests on a local host (with no HTTPS) using selenium with ChromeDriver.

Chrome requires an https certificate, but from this question i understand that i can circumvent this using the arg --ignore-certificate-errors

I have also added to my capabilities acceptInsecureCerts, as this seems like the appropriate course of action (docs)

The response from the chromedriver is still not what I was expecting:

This site can’t provide a secure connection app sent an invalid response. ERR_SSL_PROTOCOL_ERROR

My code is below:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

# make options (principally to ignore certificate)
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')

# add acceptInsecureCerts
capabilities = options.to_capabilities()
capabilities['acceptInsecureCerts'] = True

print(capabilities) # see below

driver = webdriver.Remote(
    command_executor=SELENIUM_HUB,
    desired_capabilities=capabilities
)
print(driver.__dict__) # see further below

app_login_url = 'http://app:8000/accounts/login/'

driver.get(app_login_url)

My capabilities:

{'acceptInsecureCerts': True,
'browserName': 'chrome',
'goog:chromeOptions': {'args': ['--ignore-certificate-errors'],
                        'extensions': []},
'platform': 'ANY',
'version': ''}

Here is my driver info, it looks like only the acceptInsecureCerts arg has been taken into account:

{'_file_detector': <selenium.webdriver.remote.file_detector.LocalFileDetector object at 0x7fb42bde10f0>,
'_is_remote': True,
'_mobile': <selenium.webdriver.remote.mobile.Mobile object at 0x7fb42bb5e400>,
'_switch_to': <selenium.webdriver.remote.switch_to.SwitchTo object at 0x7fb42bdd4898>,
'capabilities': {'acceptInsecureCerts': True,
                'acceptSslCerts': True,
                'applicationCacheEnabled': False,
                'browserConnectionEnabled': False,
                'browserName': 'chrome',
                'chrome': {'chromedriverVersion': '74.0.3729.6 '
                                                    '(255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29})',
                            'userDataDir': '/tmp/.com.google.Chrome.vc1ZvB'},
                'cssSelectorsEnabled': True,
                'databaseEnabled': False,
                'goog:chromeOptions': {'debuggerAddress': 'localhost:40815'},
                'handlesAlerts': True,
                'hasTouchScreen': False,
                'javascriptEnabled': True,
                'locationContextEnabled': True,
                'mobileEmulationEnabled': False,
                'nativeEvents': True,
                'networkConnectionEnabled': False,
                'pageLoadStrategy': 'normal',
                'platform': 'Linux',
                'proxy': {},
                'rotatable': False,
                'setWindowRect': True,
                'strictFileInteractability': False,
                'takesHeapSnapshot': True,
                'takesScreenshot': True,
                'timeouts': {'implicit': 0,
                            'pageLoad': 300000,
                            'script': 30000},
                'unexpectedAlertBehaviour': 'ignore',
                'version': '74.0.3729.169',
                'webStorageEnabled': True,
                'webdriver.remote.sessionid': '1cf77f237e966bac6ca15d4d9c107423'},
'command_executor': <selenium.webdriver.remote.remote_connection.RemoteConnection object at 0x7fb42be0cf98>,
'error_handler': <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7fb427d08a20>,
'session_id': '1cf77f237e966bac6ca15d4d9c107423',
'w3c': False}

Why am i still seeing the ERR_SSL_PROTOCOL_ERROR ?

like image 209
Preston Avatar asked Jun 05 '19 09:06

Preston


People also ask

How will you handle SSL certificate on a WebDriver opened Chrome browser?

In Chrome, we use the ChromeOptions class to work with SSL certificates. We shall create an instance of this class and set the capability - setAcceptInsecureCerts to true. Finally, this property of the Chrome browser shall be passed to the webdriver object.

Why is Chrome rejecting certificates?

Update Chrome and your operating system: Sometimes an SSL certificate error can simply be due to using an outdated version of Chrome. To make sure yours is up-to-date, click on the menu. If you have an old version of the browser, you will see an “Update Google Chrome” option.

How to add SSL certificate exception in Chrome?

On the chrome://settings page and click 'Privacy and Security' in the left-hand column. Then click 'Security' and scroll down to 'Manage Certificates'. Under the "Your Certificates" tab, click "Imports" to start the certification installation process.


1 Answers

You are requesting the page through HTTP and not HTTPS. Chrome will not connect to an insecure HTTP server.

This is causing the TLS/SSL negotiation to fail.

You need to make sure your server is running HTTPS on TCP port 8000.

With the --ignore-certificate-errors option you can generate a self-signed certificate and apply that to the web server.

Then change the url line to use HTTPS.

app_login_url = 'https://app:8000/accounts/login/'
like image 81
Strom Avatar answered Oct 24 '22 22:10

Strom