How to ignore ssl_client_socket_impl.cc(1061)] handshake failed in selenium c# ChromeDriver
Asked Answered
A

3

10

I have added

 ChromeOptions options = new ChromeOptions();
 options.AddArgument("--ignore-certificate-errors-spki-list");
 options.AddArgument("--ignore-ssl-errors");
 options.AddArgument("test-type");
 options.AddArguments("-incognito");
 options.AddArgument("no-sandbox");
 options.AddArgument("--start-maximized");
 driver = new ChromeDriver(options);

But still getting:

ssl_client_socket_impl.cc(1061)] handshake failed error 

How to suppress this error from console?

enter image description here

Acnode answered 12/12, 2018 at 3:44 Comment(2)
Login Started and Login successful being successful you need to update the question with more of your binary versions, code trials and relevant HTML.Incidental
code is working fine without errors but console is printing shown handshake failed errors, how to suppress those errors from consoleAcnode
I
3

This error message...

[ERROR:ssl_client_socket_openssl.cc(855)] handshake failed; returned -1, SSL error code 1, net_error -2

...implies that the handshake failed between ChromeDriver and Chrome Browser failed at some point.


Root Cause

This error is generated due to net::SSLClientSocketImpl::DoHandshake and net::SSLClientSocketImpl implemented in ssl_client_socket_impl.cc net::SSLClientSocketImpl::DoHandshake as follows:

int SSLClientSocketImpl::DoHandshake() {
  crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
  int rv = SSL_do_handshake(ssl_.get());
  int net_error = OK;
  if (rv <= 0) {
    int ssl_error = SSL_get_error(ssl_.get(), rv);
    if (ssl_error == SSL_ERROR_WANT_CHANNEL_ID_LOOKUP) {
      // The server supports channel ID. Stop to look one up before returning to
      // the handshake.
      next_handshake_state_ = STATE_CHANNEL_ID_LOOKUP;
      return OK;
    }
    if (ssl_error == SSL_ERROR_WANT_X509_LOOKUP &&
    !ssl_config_.send_client_cert) {
      return ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
    }
    if (ssl_error == SSL_ERROR_WANT_PRIVATE_KEY_OPERATION) {
      DCHECK(ssl_config_.client_private_key);
      DCHECK_NE(kSSLClientSocketNoPendingResult, signature_result_);
      next_handshake_state_ = STATE_HANDSHAKE;
      return ERR_IO_PENDING;
    }
    OpenSSLErrorInfo error_info;
    net_error = MapLastOpenSSLError(ssl_error, err_tracer, &error_info);
    if (net_error == ERR_IO_PENDING) {
      // If not done, stay in this state
      next_handshake_state_ = STATE_HANDSHAKE;
      return ERR_IO_PENDING;
    }
    LOG(ERROR) << "handshake failed; returned " << rv << ", SSL error code "
           << ssl_error << ", net_error " << net_error;
    net_log_.AddEvent(
    NetLogEventType::SSL_HANDSHAKE_ERROR,
    CreateNetLogOpenSSLErrorCallback(net_error, ssl_error, error_info));
  }
  next_handshake_state_ = STATE_HANDSHAKE_COMPLETE;
  return net_error;
}

As per ERROR:ssl_client_socket_openssl.cc handshake failed the main issue is the failure of handshake when ChromeDriver handshakes with SSL pages in Chrome. Though Chromium team conducts test for SSL handshake through net_unittests, content_tests, and browser_tests but were not exhaustive. Some usecases are left out relying on the upstream tests.

Conclusion

This error won't interupt the execution of your Test Suite and you can ignore this issue for the time being till it is fixed by the Chromium Team.

Incidental answered 13/12, 2018 at 6:19 Comment(1)
thank you! that's 2 years ago... error is still there...Tania
F
2

You can restrict Chromium's log level to 3, so that only fatal errors are logged. Please bear in mind that you won't see any other error-related messages which might cause mayhem in production! The code looks like this:

var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("log-level=3");
var driver = new ChromeDriver(options : chromeOptions);

Chromium log levels are:

Description Value
INFO 0
WARNING 1
LOG_ERROR 2
LOG_FATAL 3
Farseeing answered 7/6, 2021 at 17:38 Comment(0)
O
0

If you encounter similar errors when using selenium and can not fix it by AddArgument("--ignore-certificate-errors"). solution: 1.AddArgument("log-level=3"),but this will not catch any error log so you can catch error log by (try catch) like this 2.

try
{
   // your code
}
catch(Execption ex)
{
   console.writeline(ex.ToString())
}

Does anyone know of any unintended consequences if this is done?

Oakleil answered 3/11, 2023 at 7:3 Comment(1)
Hello, please format your answer (you mixed the answer and the code). Thanks!Heuer

© 2022 - 2024 — McMap. All rights reserved.