'Selenium-ChromeDriver SSL error/handshake failed
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.
Solution 1:[1]
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());
}
Solution 2:[2]
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".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 123 456 789 0 |
| Solution 2 | Jie Yin |
