[glib-networking/rufferson/openssl/tests/other: 2/7] Add EOF handling to gtlsconnection-openssl:end_openssl_io
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/rufferson/openssl/tests/other: 2/7] Add EOF handling to gtlsconnection-openssl:end_openssl_io
- Date: Mon, 6 Jul 2020 11:57:23 +0000 (UTC)
commit c73f250ad922ebaad259cdc863a4f3a77357db44
Author: Ruslan N. Marchenko <me ruff mobi>
Date: Fri Jun 19 20:25:11 2020 +0200
Add EOF handling to gtlsconnection-openssl:end_openssl_io
tls/openssl/gtlsconnection-openssl.c | 15 ++++++++++++++-
tls/tests/connection.c | 5 -----
2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index a05c81a..020aa0d 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -207,7 +207,20 @@ end_openssl_io (GTlsConnectionOpenssl *openssl,
/* FIXME: this is just for debug */
g_message ("end_openssl_io %s: %d, %d, %d", G_IS_TLS_CLIENT_CONNECTION (openssl) ? "client" : "server",
err_code, err_lib, reason);
- if (error && !*error)
+ if (ret == 0 && err == 0 && err_lib == 0 && err_code == SSL_ERROR_SYSCALL
+ && (direction == G_IO_IN || direction == G_IO_OUT))
+ {
+ /* SSL_ERROR_SYSCALL usually means we have no bloody idea what has happened
+ * but when ret for read or write is 0 and all others error codes as well
+ * - this is normally Early EOF condition
+ */
+ if (!g_tls_connection_get_require_close_notify (G_TLS_CONNECTION (openssl)))
+ return G_TLS_CONNECTION_BASE_OK;
+
+ if (error && !*error)
+ *error = g_error_new (G_TLS_ERROR, G_TLS_ERROR_EOF, _("%s: The connection is broken"), err_prefix);
+ }
+ else if (error && !*error)
*error = g_error_new (G_TLS_ERROR, G_TLS_ERROR_MISC, "%s: %s", err_prefix, err_str);
return G_TLS_CONNECTION_BASE_ERROR;
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index 6230358..83d8853 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -1946,11 +1946,6 @@ test_unclean_close_by_server (TestConnection *test,
GTlsConnection *client_connection;
gssize nread;
-#ifdef BACKEND_IS_OPENSSL
- g_test_skip ("this new test does not work with openssl, more research needed");
- return;
-#endif
-
start_async_server_service (test, G_TLS_AUTHENTICATION_NONE, HANDSHAKE_ONLY);
client = g_socket_client_new ();
g_socket_client_set_tls (client, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]