Ssl error zero return

SSL_get_error - obtain result code for TLS/SSL I/O operation

NAME

SSL_get_error — obtain result code for TLS/SSL I/O operation

SYNOPSIS

 #include <openssl/ssl.h>

 int SSL_get_error(const SSL *ssl, int ret);

DESCRIPTION

SSL_get_error() returns a result code (suitable for the C «switch» statement) for a preceding call to SSL_connect(), SSL_accept(), SSL_do_handshake(), SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_shutdown(), SSL_write_ex() or SSL_write() on ssl. The value returned by that TLS/SSL I/O function must be passed to SSL_get_error() in parameter ret.

In addition to ssl and ret, SSL_get_error() inspects the current thread’s OpenSSL error queue. Thus, SSL_get_error() must be used in the same thread that performed the TLS/SSL I/O operation, and no other OpenSSL function calls should appear in between. The current thread’s error queue must be empty before the TLS/SSL I/O operation is attempted, or SSL_get_error() will not work reliably.

RETURN VALUES

The following return values can currently occur:

SSL_ERROR_NONE

The TLS/SSL I/O operation completed. This result code is returned if and only if ret > 0.

SSL_ERROR_ZERO_RETURN

The TLS/SSL peer has closed the connection for writing by sending the close_notify alert. No more data can be read. Note that SSL_ERROR_ZERO_RETURN does not necessarily indicate that the underlying transport has been closed.

SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE

The operation did not complete and can be retried later.

SSL_ERROR_WANT_READ is returned when the last operation was a read operation from a nonblocking BIO. It means that not enough data was available at this time to complete the operation. If at a later time the underlying BIO has data available for reading the same function can be called again.

SSL_read() and SSL_read_ex() can also set SSL_ERROR_WANT_READ when there is still unprocessed data available at either the SSL or the BIO layer, even for a blocking BIO. See SSL_read(3) for more information.

SSL_ERROR_WANT_WRITE is returned when the last operation was a write to a nonblocking BIO and it was unable to sent all data to the BIO. When the BIO is writable again, the same function can be called again.

Note that the retry may again lead to an SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition. There is no fixed upper limit for the number of iterations that may be necessary until progress becomes visible at application protocol level.

It is safe to call SSL_read() or SSL_read_ex() when more data is available even when the call that set this error was an SSL_write() or SSL_write_ex(). However, if the call was an SSL_write() or SSL_write_ex(), it should be called again to continue sending the application data.

For socket BIOs (e.g. when SSL_set_fd() was used), select() or poll() on the underlying socket can be used to find out when the TLS/SSL I/O function should be retried.

Caveat: Any TLS/SSL I/O function can lead to either of SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE. In particular, SSL_read_ex(), SSL_read(), SSL_peek_ex(), or SSL_peek() may want to write data and SSL_write() or SSL_write_ex() may want to read data. This is mainly because TLS/SSL handshakes may occur at any time during the protocol (initiated by either the client or the server); SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_write_ex(), and SSL_write() will handle any pending handshakes.

SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT

The operation did not complete; the same TLS/SSL I/O function should be called again later. The underlying BIO was not connected yet to the peer and the call would block in connect()/accept(). The SSL function should be called again when the connection is established. These messages can only appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively. In order to find out, when the connection has been successfully established, on many platforms select() or poll() for writing on the socket file descriptor can be used.

SSL_ERROR_WANT_X509_LOOKUP

The operation did not complete because an application callback set by SSL_CTX_set_client_cert_cb() has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application.

SSL_ERROR_WANT_ASYNC

The operation did not complete because an asynchronous engine is still processing data. This will only occur if the mode has been set to SSL_MODE_ASYNC using SSL_CTX_set_mode(3) or SSL_set_mode(3) and an asynchronous capable engine is being used. An application can determine whether the engine has completed its processing using select() or poll() on the asynchronous wait file descriptor. This file descriptor is available by calling SSL_get_all_async_fds(3) or SSL_get_changed_async_fds(3). The TLS/SSL I/O function should be called again later. The function must be called from the same thread that the original call was made from.

SSL_ERROR_WANT_ASYNC_JOB

The asynchronous job could not be started because there were no async jobs available in the pool (see ASYNC_init_thread(3)). This will only occur if the mode has been set to SSL_MODE_ASYNC using SSL_CTX_set_mode(3) or SSL_set_mode(3) and a maximum limit has been set on the async job pool through a call to ASYNC_init_thread(3). The application should retry the operation after a currently executing asynchronous operation for the current thread has completed.

SSL_ERROR_WANT_CLIENT_HELLO_CB

The operation did not complete because an application callback set by SSL_CTX_set_client_hello_cb() has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application.

SSL_ERROR_SYSCALL

Some non-recoverable, fatal I/O error occurred. The OpenSSL error queue may contain more information on the error. For socket I/O on Unix systems, consult errno for details. If this error occurs then no further I/O operations should be performed on the connection and SSL_shutdown() must not be called.

This value can also be returned for other errors, check the error queue for details.

SSL_ERROR_SSL

A non-recoverable, fatal error in the SSL library occurred, usually a protocol error. The OpenSSL error queue contains more information on the error. If this error occurs then no further I/O operations should be performed on the connection and SSL_shutdown() must not be called.

BUGS

The SSL_ERROR_SYSCALL with errno value of 0 indicates unexpected EOF from the peer. This will be properly reported as SSL_ERROR_SSL with reason code SSL_R_UNEXPECTED_EOF_WHILE_READING in the OpenSSL 3.0 release because it is truly a TLS protocol error to terminate the connection without a SSL_shutdown().

The issue is kept unfixed in OpenSSL 1.1.1 releases because many applications which choose to ignore this protocol error depend on the existing way of reporting the error.

SEE ALSO

ssl(7)

HISTORY

The SSL_ERROR_WANT_ASYNC error code was added in OpenSSL 1.1.0. The SSL_ERROR_WANT_CLIENT_HELLO_CB error code was added in OpenSSL 1.1.1.

COPYRIGHT

Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the OpenSSL license (the «License»). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.

NAME

SSL_get_error — obtain result code for TLS/SSL I/O operation

SYNOPSIS

#include <openssl/ssl.h>

int SSL_get_error(const SSL *ssl, int ret);

DESCRIPTION

SSL_get_error() returns a result code (suitable for the C «switch» statement) for a preceding call to SSL_connect(), SSL_accept(), SSL_do_handshake(), SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_shutdown(), SSL_write_ex() or SSL_write() on ssl. The value returned by that TLS/SSL I/O function must be passed to SSL_get_error() in parameter ret.

In addition to ssl and ret, SSL_get_error() inspects the current thread’s OpenSSL error queue. Thus, SSL_get_error() must be used in the same thread that performed the TLS/SSL I/O operation, and no other OpenSSL function calls should appear in between. The current thread’s error queue must be empty before the TLS/SSL I/O operation is attempted, or SSL_get_error() will not work reliably.

NOTES

Some TLS implementations do not send a close_notify alert on shutdown.

On an unexpected EOF, versions before OpenSSL 3.0 returned SSL_ERROR_SYSCALL, nothing was added to the error stack, and errno was 0. Since OpenSSL 3.0 the returned error is SSL_ERROR_SSL with a meaningful error on the error stack.

RETURN VALUES

The following return values can currently occur:

SSL_ERROR_NONE

The TLS/SSL I/O operation completed. This result code is returned if and only if ret > 0.

SSL_ERROR_ZERO_RETURN

The TLS/SSL peer has closed the connection for writing by sending the close_notify alert. No more data can be read. Note that SSL_ERROR_ZERO_RETURN does not necessarily indicate that the underlying transport has been closed.

This error can also appear when the option SSL_OP_IGNORE_UNEXPECTED_EOF is set. See SSL_CTX_set_options(3) for more details.

SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE

The operation did not complete and can be retried later.

For non-QUIC SSL objects, SSL_ERROR_WANT_READ is returned when the last operation was a read operation from a nonblocking BIO. It means that not enough data was available at this time to complete the operation. If at a later time the underlying BIO has data available for reading the same function can be called again.

SSL_read() and SSL_read_ex() can also set SSL_ERROR_WANT_READ when there is still unprocessed data available at either the SSL or the BIO layer, even for a blocking BIO. See SSL_read(3) for more information.

For non-QUIC SSL objects, SSL_ERROR_WANT_WRITE is returned when the last operation was a write to a nonblocking BIO and it was unable to sent all data to the BIO. When the BIO is writable again, the same function can be called again.

Note that the retry may again lead to an SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition. There is no fixed upper limit for the number of iterations that may be necessary until progress becomes visible at application protocol level.

For QUIC SSL objects, the meaning of SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE have different but largely compatible semantics. Since QUIC implements its own flow control and uses UDP datagrams, backpressure conditions in terms of the underlying BIO providing network I/O are not directly relevant to the circumstances in which these errors are produced. In particular, SSL_ERROR_WANT_WRITE indicates that the OpenSSL internal send buffer for a given QUIC stream has been filled. Likewise, SSL_ERROR_WANT_READ indicates that the OpenSSL internal receive buffer for a given QUIC stream is empty.

It is safe to call SSL_read() or SSL_read_ex() when more data is available even when the call that set this error was an SSL_write() or SSL_write_ex(). However, if the call was an SSL_write() or SSL_write_ex(), it should be called again to continue sending the application data. If you get SSL_ERROR_WANT_WRITE from SSL_write() or SSL_write_ex() then you should not do any other operation that could trigger IO other than to repeat the previous SSL_write() call.

For socket BIOs (e.g. when SSL_set_fd() was used), select() or poll() on the underlying socket can be used to find out when the TLS/SSL I/O function should be retried.

Caveat: Any TLS/SSL I/O function can lead to either of SSL_ERROR_WANT_READ and SSL_ERROR_WANT_WRITE. In particular, SSL_read_ex(), SSL_read(), SSL_peek_ex(), or SSL_peek() may want to write data and SSL_write() or SSL_write_ex() may want to read data. This is mainly because TLS/SSL handshakes may occur at any time during the protocol (initiated by either the client or the server); SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_write_ex(), and SSL_write() will handle any pending handshakes.

SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT

The operation did not complete; the same TLS/SSL I/O function should be called again later. The underlying BIO was not connected yet to the peer and the call would block in connect()/accept(). The SSL function should be called again when the connection is established. These messages can only appear with a BIO_s_connect() or BIO_s_accept() BIO, respectively. In order to find out, when the connection has been successfully established, on many platforms select() or poll() for writing on the socket file descriptor can be used.

SSL_ERROR_WANT_X509_LOOKUP

The operation did not complete because an application callback set by SSL_CTX_set_client_cert_cb() has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application.

SSL_ERROR_WANT_ASYNC

The operation did not complete because an asynchronous engine is still processing data. This will only occur if the mode has been set to SSL_MODE_ASYNC using SSL_CTX_set_mode(3) or SSL_set_mode(3) and an asynchronous capable engine is being used. An application can determine whether the engine has completed its processing using select() or poll() on the asynchronous wait file descriptor. This file descriptor is available by calling SSL_get_all_async_fds(3) or SSL_get_changed_async_fds(3). The TLS/SSL I/O function should be called again later. The function must be called from the same thread that the original call was made from.

SSL_ERROR_WANT_ASYNC_JOB

The asynchronous job could not be started because there were no async jobs available in the pool (see ASYNC_init_thread(3)). This will only occur if the mode has been set to SSL_MODE_ASYNC using SSL_CTX_set_mode(3) or SSL_set_mode(3) and a maximum limit has been set on the async job pool through a call to ASYNC_init_thread(3). The application should retry the operation after a currently executing asynchronous operation for the current thread has completed.

SSL_ERROR_WANT_CLIENT_HELLO_CB

The operation did not complete because an application callback set by SSL_CTX_set_client_hello_cb() has asked to be called again. The TLS/SSL I/O function should be called again later. Details depend on the application.

SSL_ERROR_SYSCALL

Some non-recoverable, fatal I/O error occurred. The OpenSSL error queue may contain more information on the error. For socket I/O on Unix systems, consult errno for details. If this error occurs then no further I/O operations should be performed on the connection and SSL_shutdown() must not be called.

This value can also be returned for other errors, check the error queue for details.

SSL_ERROR_SSL

A non-recoverable, fatal error in the SSL library occurred, usually a protocol error. The OpenSSL error queue contains more information on the error. If this error occurs then no further I/O operations should be performed on the connection and SSL_shutdown() must not be called.

SEE ALSO

ssl(7)

HISTORY

The SSL_ERROR_WANT_ASYNC error code was added in OpenSSL 1.1.0. The SSL_ERROR_WANT_CLIENT_HELLO_CB error code was added in OpenSSL 1.1.1.

COPYRIGHT

Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the «License»). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.

Содержание

  1. Support Questions
  2. Support Questions
  3. Support Questions
  4. SSL_Read () возвращает SSL_ERROR_ZERO_RETURN, но ERR_get_error () равен 0
  5. Решение
  6. SSL_read() failed (SSL: error:0A000126:SSL routines::unexpected eof while reading) #18866
  7. Comments
  8. openssl version -a
  9. lsb_release -a
  10. apache2 -V

Support Questions

  • Subscribe to RSS Feed
  • Mark Question as New
  • Mark Question as Read
  • Float this Question for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page

Created on ‎10-18-2019 02:17 AM — last edited on ‎10-18-2019 03:46 AM by VidyaSargur

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

i’m using with R programming the library DBI (developed by Rstudio) that used impala obbc 64-bit.

Sometimes impala return data and sometimes connection fall down and R give to me:

how check i can make to solve the problem?

thank in advance

Created ‎10-28-2019 02:30 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

it’s problem about timeout parameters and rows fetched blocks, eith long running query connection fall down!

Created ‎08-09-2021 08:01 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Created ‎08-10-2021 12:45 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Open the ODBC application in Windows and click on any one of the DSN and further click on Advanced Options. to get the above window.

Created ‎08-10-2021 01:27 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

I am using Rstudio web so do not need to configure ODBC on windows.

Created ‎08-10-2021 07:34 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Rstudio is an application which I guess might be running on windows or mac OS. On these OS you will be downloading the ODBC application where you configure the DSN parameters. Under that configuration only, there is an Advanced Option where you will find the properties.

Источник

Support Questions

  • Subscribe to RSS Feed
  • Mark Question as New
  • Mark Question as Read
  • Float this Question for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page

Created on ‎10-18-2019 02:17 AM — last edited on ‎10-18-2019 03:46 AM by VidyaSargur

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

i’m using with R programming the library DBI (developed by Rstudio) that used impala obbc 64-bit.

Sometimes impala return data and sometimes connection fall down and R give to me:

how check i can make to solve the problem?

thank in advance

Created ‎10-28-2019 02:30 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

it’s problem about timeout parameters and rows fetched blocks, eith long running query connection fall down!

Created ‎08-09-2021 08:01 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Created ‎08-10-2021 12:45 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Open the ODBC application in Windows and click on any one of the DSN and further click on Advanced Options. to get the above window.

Created ‎08-10-2021 01:27 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

I am using Rstudio web so do not need to configure ODBC on windows.

Created ‎08-10-2021 07:34 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Rstudio is an application which I guess might be running on windows or mac OS. On these OS you will be downloading the ODBC application where you configure the DSN parameters. Under that configuration only, there is an Advanced Option where you will find the properties.

Источник

Support Questions

  • Subscribe to RSS Feed
  • Mark Question as New
  • Mark Question as Read
  • Float this Question for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page

Created on ‎10-18-2019 02:17 AM — last edited on ‎10-18-2019 03:46 AM by VidyaSargur

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

i’m using with R programming the library DBI (developed by Rstudio) that used impala obbc 64-bit.

Sometimes impala return data and sometimes connection fall down and R give to me:

how check i can make to solve the problem?

thank in advance

Created ‎10-28-2019 02:30 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

it’s problem about timeout parameters and rows fetched blocks, eith long running query connection fall down!

Created ‎08-09-2021 08:01 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Created ‎08-10-2021 12:45 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Open the ODBC application in Windows and click on any one of the DSN and further click on Advanced Options. to get the above window.

Created ‎08-10-2021 01:27 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

I am using Rstudio web so do not need to configure ODBC on windows.

Created ‎08-10-2021 07:34 AM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Rstudio is an application which I guess might be running on windows or mac OS. On these OS you will be downloading the ODBC application where you configure the DSN parameters. Under that configuration only, there is an Advanced Option where you will find the properties.

Источник

SSL_Read () возвращает SSL_ERROR_ZERO_RETURN, но ERR_get_error () равен 0

Я пишу неблокирующий клиент Websocket и использую OpenSSL для уровня TLS. Я могу подключиться к удаленному серверу, выполнить квитирование TLS, отправить запрос на обновление, получить ответ, подтверждающий обновление, и получить реальный ответ через веб-сокет, прежде чем уровень TLS отключится с помощью SSL_ERROR_ZERO_RETURN ,

SSL_get_error(. ) возвращает: 6 // SSL_ERROR_ZERO_RETURN

ERR_error_string(ERR_get_error(), nullptr) возвращает: error:00000000:lib(0):func(0):reason(0)

Из моего понимания, ERR_get_error() должен появиться и вернуть первую ошибку в очередь ошибок, и SSL_get_error() возвращает последнюю ошибку SSL_* функция. я не понимаю почему SSL_get_error() вернет значение ошибки, но ERR_get_error() не. Согласно этому предыдущему Вопрос переполнения стека , SSL_get_error() НЕ звонит ERR_get_error() ,

Следующий код вызывается повторно (так как это неблокирующий сокет):

У меня есть два вопроса:

Почему я не получаю значение ошибки для ERR_get_error ()?

Почему я так быстро отключаюсь после установления сеанса TLS и Websocket?

РЕДАКТИРОВАТЬ 1

Я использовал wireshark для захвата пакетов между клиентом и сервером. Я подтвердил, что квитирование TLS, обновление websocket и первоначальный ответ сервера были успешными. Я заметил, что после первоначального ответа сервера мой клиент получает Encrypted Alert 21 с сервера, который, по моему мнению, является фатальной ошибкой и объясняет, почему сеанс TLS завершается немедленно, а моя очередь ошибок SSL пуста (хотя это, вероятно, проблема на стороне клиента, я не думаю, что это результат недавнего действия), и вид объясняет SSL_ERROR_ZERO_RETURN значение, которое я получаю после SSL_Read ,

Я не уверен, что Encrypted Alert 21 влечет за собой. Это может быть сертификат, который я использую (самоподписанный). Нужно расследовать дальше.

Решение

Хорошо, коренная причина проблемы была определена, но было прыгнуто много обручей, и время было потрачено, чтобы добраться туда. Я смог расшифровать трафик SSL, взяв главный ключ, используя метод OpenSSL, SSL_SESSION_get_master_key () , и случайное значение Hello клиента с помощью wireshark.

Соответствующий код для вывода мастер-ключа после SSL_Connect:

С использованием Журнал ключей NSS CLIENT_RANDOM Формат в Wireshark для расшифровки захваченного трафика SSL, я смог изучить вышеупомянутые Encrypted Alert 21 который в итоге оказался просто WebSocket FIN и close_notify.

Оказывается, основной причиной было то, что во время рукопожатия мое сообщение с запросом на обновление WSS действительно содержало правильные заголовки, но я фактически отправлял полезную нагрузку вместе с ним. Это был случай установки размера с помощью sizeof буфера сообщений вместо strlen при отправке сообщения. Сервер отлично бы проанализировал сообщение Upgrade и успешно завершил рукопожатие, но в следующий раз, когда он проверял свой сокет, он считывал мусор, когда ожидал сообщение WSS. Это вызвало внезапное закрытие соединения websocket.

В заключение, чтобы ответить на мои оригинальные два вопроса:

  1. Почему я не получаю значение ошибки для ERR_get_error ()?

Соединение прерывается на стороне сервера, а очередь ошибок будет содержать ошибки на стороне клиента, которых нет, по крайней мере на уровне SSL / TLS.

  1. Почему я так быстро отключаюсь после установления сеанса TLS и Websocket?

Мой начальный запрос на обновление содержал действительный запрос на обновление Websocket, за которым следовали данные мусора. Сервер проанализировал запрос на обновление Websocket, подтвердил обновление и начал отправлять данные обратно. В следующий раз, когда сервер проверил свой сокет, у него все еще были значения мусора, которые были отправлены с оригинальным Запросом на обновление Websocket. Поскольку сервер не распознал его как допустимое сообщение Websocket или что-либо еще в этом отношении, он решил разорвать соединение с close_notify ,

Источник

SSL_read() failed (SSL: error:0A000126:SSL routines::unexpected eof while reading) #18866

Hello, 2-3 weeks ago i started getting errors from my website based on laravel:

I can’t find any reasons or solution of this error.
OS :
Ubuntu 22.04 LTS

php -v :
PHP 8.1.2 (cli) (built: Jun 13 2022 13:52:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

openssl version -a :
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

nginx -v :
nginx version: nginx/1.18.0 (Ubuntu)

SSL certificate from Let’s encrypt via certbot

The text was updated successfully, but these errors were encountered:

Has the OpenSSL version been updated? OpenSSL 3 (a major release) changed some behaviour compared to 1.1.1 with respect to peers that fail to shutdown a TLS connection cleanly.

Previously, if a peer unexpectedly shutdown a connection an OpenSSL IO function (such as SSL_read() ) would report an error and SSL_get_error() would report SSL_ERROR_SYSCALL and errno would be 0. This was considered a bug in 1.1.1 (you should never get SSL_ERROR_SYSCALL but with errno as 0). However fixing it in 1.1.1 broke some apps. We delayed the fix until the next major version (OpenSSL 3.0).

In OpenSSL 3.0 this error is now reported from SSL_get_error() as SSL_ERROR_SSL and the unexpeced eof while reading error is put on the OpenSSL error stack. We also added a new option SSL_OP_IGNORE_UNEXPECTED_EOF which treats an unexpected EOF from the peer as if they had performed an orderly shutdown. See:

Supposedly the nginx used does not set the new option where it should do so.

Updating nginx resolve the problem for me.
Ubuntu default nginx version 1.18 is old. The newest version is 1.22.

Hope this may help you.

i cant update to new version nginx 1.22 becasue passenger not support
how i can solve it manualy

My public facing site is bombarded by these messages in the nginx error.log.

A quick ‘dig -x’ shows hostnames that are not consistent with our target audience.
Also, one host causes the messages for way longer then typical for our site usage.

Is it possible these messages are caused by some probes looking to break into SSL sessions?

(ps: ubuntu 22.04 updated almost weekly)

i cant update to new version nginx 1.22 becasue passenger not support how i can solve it manualy

I have the same issue with Passenger holding me back and getting this massive stream of errors, a lot are from the same IP’s again and again, so I think its bots hunting around. My site seems fine to access from all devices I can test it on and on https://globalsign.ssllabs.com/

I got theys errors with Apache2 ..

[Sun Sep 04 13:44:07.303103 2022] [ssl:info] [pid 86541] (70014)End of file found: [client 213.216.205.177:60718] AH02008: SSL library error 1 in handshake (server thesite.fi:443)
[Sun Sep 04 13:44:07.303116 2022] [ssl:info] [pid 86541] SSL Library Error: error:0A000126:SSL routines::unexpected eof while reading

openssl version -a

OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
built on: Mon Jul 4 11:20:23 2022 UTC
platform: debian-amd64
options: bn(64,64)
compiler: gcc -fPIC -pthread -m64 -Wa,—noexecstack -Wall -Wa,—noexecstack -g -O2 -ffile-prefix-map=/build/openssl-Q8dQt3/openssl-3.0.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: «/usr/lib/ssl»
ENGINESDIR: «/usr/lib/x86_64-linux-gnu/engines-3»
MODULESDIR: «/usr/lib/x86_64-linux-gnu/ossl-modules»
Seeding source: os-specific
CPUINFO: OPENSSL_ia32cap=0x7ffaf3bfffebffff:0x29c67af

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy

apache2 -V

Server version: Apache/2.4.52 (Ubuntu)
Server built: 2022-06-14T12:30:21
Server’s Module Magic Number: 20120211:121
Server loaded: APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM:
Server compiled with.
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT=»/etc/apache2″
-D SUEXEC_BIN=»/usr/lib/apache2/suexec»
-D DEFAULT_PIDLOG=»/var/run/apache2.pid»
-D DEFAULT_SCOREBOARD=»logs/apache_runtime_status»
-D DEFAULT_ERRORLOG=»logs/error_log»
-D AP_TYPES_CONFIG_FILE=»mime.types»
-D SERVER_CONFIG_FILE=»apache2.conf»

I got letsencrypt’s certs, they are ok. Just updated by force.

Источник

Я пишу неблокирующий клиент Websocket и использую OpenSSL для уровня TLS. Я могу подключиться к удаленному серверу, выполнить квитирование TLS, отправить запрос на обновление, получить ответ, подтверждающий обновление, и получить реальный ответ через веб-сокет, прежде чем уровень TLS отключится с помощью SSL_ERROR_ZERO_RETURN,

SSL_get_error(...) возвращает: 6 // SSL_ERROR_ZERO_RETURN

ERR_error_string(ERR_get_error(), nullptr) возвращает: error:00000000:lib(0):func(0):reason(0)

Из моего понимания, ERR_get_error() должен появиться и вернуть первую ошибку в очередь ошибок, и SSL_get_error() возвращает последнюю ошибку SSL_* функция. я не понимаю почему SSL_get_error() вернет значение ошибки, но ERR_get_error() не. Согласно этому предыдущему Вопрос переполнения стека, SSL_get_error() НЕ звонит ERR_get_error(),

Следующий код вызывается повторно (так как это неблокирующий сокет):

ERR_clear_error();
int ret = SSL_read(...);
if (ret > 0) {
// read bytes from socket
} else {
int err_code = SSL_get_error(ssl_session_, ret);
if (err_code == SSL_ERROR_ZERO_RETURN || err_code == SSL_ERROR_SYSCALL || err_code == SSL_ERROR_SSL) {
sprintf("Disconnected: %d %s", err_code, ERR_error_string(ERR_get_error(), nullptr));
// Disconnect Code
}
}

У меня есть два вопроса:

  1. Почему я не получаю значение ошибки для ERR_get_error ()?

  2. Почему я так быстро отключаюсь после установления сеанса TLS и Websocket?

РЕДАКТИРОВАТЬ 1

Я использовал wireshark для захвата пакетов между клиентом и сервером. Я подтвердил, что квитирование TLS, обновление websocket и первоначальный ответ сервера были успешными. Я заметил, что после первоначального ответа сервера мой клиент получает Encrypted Alert 21 с сервера, который, по моему мнению, является фатальной ошибкой и объясняет, почему сеанс TLS завершается немедленно, а моя очередь ошибок SSL пуста (хотя это, вероятно, проблема на стороне клиента, я не думаю, что это результат недавнего действия), и вид объясняет SSL_ERROR_ZERO_RETURN значение, которое я получаю после SSL_Read,

Я не уверен, что Encrypted Alert 21 влечет за собой. Это может быть сертификат, который я использую (самоподписанный). Нужно расследовать дальше.

0

Решение

Хорошо, коренная причина проблемы была определена, но было прыгнуто много обручей, и время было потрачено, чтобы добраться туда. Я смог расшифровать трафик SSL, взяв главный ключ, используя метод OpenSSL, SSL_SESSION_get_master_key (), и случайное значение Hello клиента с помощью wireshark.

Соответствующий код для вывода мастер-ключа после SSL_Connect:

ERR_clear_error();
int ret = SSL_connect(ssl_ptr);
if (ret > 0) {
SSL_SESSION * ssl_session = SSL_get_session(ssl_ptr);
if(ssl_session != NULL) {
unsigned char master_key_buf[256];
size_t outlen = sizeof(master_key_buf);
size_t buf_size = SSL_SESSION_get_master_key(ssl_session, master_key_buf, outlen);
if(outlen > 0) {
char hex_encoded_master_buf[513];
// hex encode the master key
for(size_t i = 0; i < buf_size; ++i) {
sprintf(&hex_encoded_master_buf[2*i], "%02x", master_key_buf[i]);
}
hex_encoded_master_buf[(2*buf_size)] = '';
// log out the hex-encoded master key in master buf here
}
}
}

С использованием Журнал ключей NSS CLIENT_RANDOM Формат в Wireshark для расшифровки захваченного трафика SSL, я смог изучить вышеупомянутые Encrypted Alert 21 который в итоге оказался просто WebSocket FIN и close_notify.

Оказывается, основной причиной было то, что во время рукопожатия мое сообщение с запросом на обновление WSS действительно содержало правильные заголовки, но я фактически отправлял полезную нагрузку вместе с ним. Это был случай установки размера с помощью sizeof буфера сообщений вместо strlen при отправке сообщения. Сервер отлично бы проанализировал сообщение Upgrade и успешно завершил рукопожатие, но в следующий раз, когда он проверял свой сокет, он считывал мусор, когда ожидал сообщение WSS. Это вызвало внезапное закрытие соединения websocket.

В заключение, чтобы ответить на мои оригинальные два вопроса:

  1. Почему я не получаю значение ошибки для ERR_get_error ()?

Соединение прерывается на стороне сервера, а очередь ошибок будет содержать ошибки на стороне клиента, которых нет, по крайней мере на уровне SSL / TLS.

  1. Почему я так быстро отключаюсь после установления сеанса TLS и Websocket?

Мой начальный запрос на обновление содержал действительный запрос на обновление Websocket, за которым следовали данные мусора. Сервер проанализировал запрос на обновление Websocket, подтвердил обновление и начал отправлять данные обратно. В следующий раз, когда сервер проверил свой сокет, у него все еще были значения мусора, которые были отправлены с оригинальным Запросом на обновление Websocket. Поскольку сервер не распознал его как допустимое сообщение Websocket или что-либо еще в этом отношении, он решил разорвать соединение с close_notify,

-1

Другие решения

Других решений пока нет …

Понравилась статья? Поделить с друзьями:
  • Ssl error when connecting to the jack server try jack diagnose
  • Srv008018 ошибка гис жкх как устранить
  • Srttrail txt ошибка при загрузке windows 10
  • Srttrail txt windows 10 ошибка при восстановлении системы
  • Srt trail txt ошибка windows 10