Search code examples
seleniumgoogle-chromeselenium-webdriverwebdriverselenium-chromedriver

ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed with ChromeDriver Chrome browser and Selenium


When running my python selenium script with Chrome driver I get about three of the below error messages every time a page loads even though everything works fine. Is there a way to suppress these messages?

[24412:18772:0617/090708:ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed; returned -1, SSL error code 1, net_error -100


Solution

  • You get this error when the browser asks you to accept the certificate from a website. You can set to ignore these errors by default in order avoid these errors.

    For Chrome, you need to add --ignore-certificate-errors and --ignore-ssl-errors ChromeOptions() argument:

    options = webdriver.ChromeOptions()
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--ignore-ssl-errors')
    driver = webdriver.Chrome(chrome_options=options)
    

    For the Firefox, you need to set accept_untrusted_certs FirefoxProfile() option to True:

    profile = webdriver.FirefoxProfile()
    profile.accept_untrusted_certs = True
    driver = webdriver.Firefox(firefox_profile=profile)
    

    For the Internet Explorer, you need to set acceptSslCerts desired capability:

    capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
    capabilities['acceptSslCerts'] = True
    driver = webdriver.Ie(capabilities=capabilities)