Selenium-ChromeDriver SSL error/handshake failed
Asked Answered
F

5

14

My script is throwing a ton of SSL errors as below:

[19852:2032:0912/202419:ERROR:ssl_client_socket_impl.cc(1141)] handshake failed;
 returned -1, SSL error code 1, net_error -100

[19852:2032:0912/202419:ERROR:ssl_client_socket_impl.cc(1141)] handshake failed;
 returned -1, SSL error code 1, net_error -100

Everything works normally but the errors keep looping and eventually block the script causing it all to come to a halt.

I have tried to suppress the errors as below...but to no effect:

path_to_chromedriver = 'C:/Path/to/Chromedriver'
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
browser = webdriver.Chrome(chrome_options=options, executable_path = path_to_chromedriver)

I am unsure if the error is in my code above if there is something I should add that isn't there, or whether these errors can actually be suppressed.

If it is helpful, this is an old piece of code that was working fine until a few days ago. The site in question added some ad network scripts which caused some SSL certificate issues.

Any help appreciated.

Farlay answered 12/9, 2016 at 19:41 Comment(4)
I'm having similar problem when trying to automate testing my Angular application which requires singing in at an external domain.Rudnick
Do you have any particular "CA" certificate to log in and monitor the page?Jelly
who is throwing this error? Python or Selenium? Also, check if your network routing changed (probably, your traffic is now routed through a proxy server. May be it is this proxy blocking you)Tolbert
Hey, did you find out how to solve this error?Jacquie
C
0

You can try using the TrustManager packages, here's a sample

    SSLContext sslContext;
    TrustManager[] tmTrustAllCerts = new TrustManager[]{
            new X509TrustManager() {
                public java.security.cert.X509Certificate[] getAcceptedIssuers()
                {
                    return null;
                }
                public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
                public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
            }
    };

    try {
        sslContext = SSLContext.getInstance("SSL");
        sslContext.init(null, tmTrustAllCerts, new SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
    }
    catch(Exception e) {
        System.out.println(e.getStackTrace());
    }
Carillon answered 24/1, 2022 at 2:48 Comment(1)
Hi and thanks for the answer. It would be great if you could explain to us how and why your code solves the OP's problem as code itself is not always easy to read.Luxe
C
0

change it from

browser = webdriver.Chrome(chrome_options=options, executable_path = path_to_chromedriver)

to

browser = webdriver.Chrome(executable_path = path_to_chromedriver, options=options)

this should solve your issue

Campy answered 31/10, 2022 at 14:47 Comment(0)
B
0

There's a several reasons why this error occurs, it could be that between your ChromeDriver and Chrome wasn't updated to the latest version or the SSL certification might be invalid / expired / not trusted by the client.

If it still doesn't work, how about if disable the QUIC protocol instead?

options = webdriver.ChromeOptions() 
options.add_argument("disable-quic")
browser = webdriver.Chrome(options=options)
Banuelos answered 19/3, 2023 at 9:21 Comment(0)
B
0

Open Browser http://127.0.0.1/8000 Chrome executable_path=C:/path/to/chromedrive options=add_argument("--ignore-certificate-errors"

Belay answered 21/4 at 9:24 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Xiphisternum
C
-1

This is due to the unsafe address error. You can ignore this by adding parameters of "--ignore-certificate-errors".

Take the case in robot framework-selenium as example:

Open Browser http://127.0.0.1/8000 Chrome executable_path=C:/path/to/chromedrive options=add_argument("--ignore-certificate-errors")

This will solve the problem you got. If you ignore this argument, there is an error of chance got a "ERROR:ssl_client_socket_impl.cc".

Carter answered 8/10, 2020 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.