diff options
author | Dan Winship <danw@src.gnome.org> | 2004-10-06 17:21:07 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2004-10-06 17:21:07 +0000 |
commit | 9b494e16960e853c6e8efe3774b302f0e04523e4 (patch) | |
tree | f22734aa595876709c53e0d7377982ab491984c0 | |
parent | 7a890d5783cc4c1770649cb9ab7fe271d514ec29 (diff) | |
download | libsoup-9b494e16960e853c6e8efe3774b302f0e04523e4.tar.gz |
add SOUP_SSL_ERROR_CERTIFICATE.
* libsoup/soup-ssl.h (SoupSocketError): add
SOUP_SSL_ERROR_CERTIFICATE.
* libsoup/soup-gnutls.c (do_handshake): Pass the GError to
verify_certificate.
(verify_certificate): Set the GError appropriately rather than
spewing g_warnings.
* libsoup/soup-socket.c (read_from_network, soup_socket_write): If
the GIOChannel operation returns an error, store it as GOBject
data on the socket (as a hack so soup-message-io.c can access it
without us needing to change SoupSocket's API).
* libsoup/soup-message-io.c (io_error): peek at the socket's
"last_error" datum and set the message's status to SSL_FAILED
(with the GError's message string) rather than IO_ERROR, if
appropriate. For 64414.
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | libsoup/soup-message-io.c | 15 | ||||
-rw-r--r-- | libsoup/soup-socket.c | 16 | ||||
-rw-r--r-- | libsoup/soup-ssl.h | 3 |
4 files changed, 49 insertions, 5 deletions
@@ -1,3 +1,23 @@ +2004-10-06 Dan Winship <danw@novell.com> + + * libsoup/soup-ssl.h (SoupSocketError): add + SOUP_SSL_ERROR_CERTIFICATE. + + * libsoup/soup-gnutls.c (do_handshake): Pass the GError to + verify_certificate. + (verify_certificate): Set the GError appropriately rather than + spewing g_warnings. + + * libsoup/soup-socket.c (read_from_network, soup_socket_write): If + the GIOChannel operation returns an error, store it as GOBject + data on the socket (as a hack so soup-message-io.c can access it + without us needing to change SoupSocket's API). + + * libsoup/soup-message-io.c (io_error): peek at the socket's + "last_error" datum and set the message's status to SSL_FAILED + (with the GError's message string) rather than IO_ERROR, if + appropriate. + 2004-09-30 Dan Winship <danw@novell.com> * libsoup/soup-gnutls.c (soup_gnutls_init): Add this, with some diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c index a8ea957c..7350378b 100644 --- a/libsoup/soup-message-io.c +++ b/libsoup/soup-message-io.c @@ -15,6 +15,7 @@ #include "soup-message.h" #include "soup-message-private.h" #include "soup-socket.h" +#include "soup-ssl.h" typedef enum { SOUP_MESSAGE_IO_CLIENT, @@ -154,8 +155,18 @@ io_error (SoupSocket *sock, SoupMessage *msg) return; } - if (!SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) - soup_message_set_status (msg, SOUP_STATUS_IO_ERROR); + if (!SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) { + GError *err = g_object_get_data (G_OBJECT (sock), + "SoupSocket-last_error"); + + if (err && err->domain == SOUP_SSL_ERROR) { + soup_message_set_status_full (msg, + SOUP_STATUS_SSL_FAILED, + err->message); + } else + soup_message_set_status (msg, SOUP_STATUS_IO_ERROR); + } + soup_message_io_finished (msg); } diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c index 1d1aaf4a..2fde20b3 100644 --- a/libsoup/soup-socket.c +++ b/libsoup/soup-socket.c @@ -880,7 +880,13 @@ read_from_network (SoupSocket *sock, gpointer buffer, gsize len, gsize *nread) if (err->domain == SOUP_SSL_ERROR && err->code == SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE) cond = G_IO_OUT; - g_error_free (err); + g_object_set_data_full (G_OBJECT (sock), + "SoupSocket-last_error", + err, (GDestroyNotify)g_error_free); + } else { + g_object_set_data (G_OBJECT (sock), + "SoupSocket-last_error", + NULL); } switch (status) { @@ -1100,7 +1106,13 @@ soup_socket_write (SoupSocket *sock, gconstpointer buffer, if (err->domain == SOUP_SSL_ERROR && err->code == SOUP_SSL_ERROR_HANDSHAKE_NEEDS_READ) cond = G_IO_IN; - g_error_free (err); + g_object_set_data_full (G_OBJECT (sock), + "SoupSocket-last_error", + err, (GDestroyNotify)g_error_free); + } else { + g_object_set_data (G_OBJECT (sock), + "SoupSocket-last_error", + NULL); } if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN) { diff --git a/libsoup/soup-ssl.h b/libsoup/soup-ssl.h index 0f7460db..c52658a6 100644 --- a/libsoup/soup-ssl.h +++ b/libsoup/soup-ssl.h @@ -30,7 +30,8 @@ GQuark soup_ssl_error_quark (void); typedef enum { SOUP_SSL_ERROR_HANDSHAKE_NEEDS_READ, - SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE + SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE, + SOUP_SSL_ERROR_CERTIFICATE, } SoupSocketError; #endif /* SOUP_SSL_H */ |