[evolution-data-server] goa-ews: Handle certificate errors during autodiscover



commit c6e74c6d9f77f26e0e37d0ded98b0ae0e2ee98b5
Author: Milan Crha <mcrha redhat com>
Date:   Wed May 18 14:55:18 2022 +0200

    goa-ews: Handle certificate errors during autodiscover
    
    If there was any certificate error during autodiscover on the GOA side,
    the user explicitly ignored the error when creating the account, thus
    the repeated autodiscover on the eds side can also ignore it.

 src/modules/gnome-online-accounts/goaewsclient.c | 31 ++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
---
diff --git a/src/modules/gnome-online-accounts/goaewsclient.c 
b/src/modules/gnome-online-accounts/goaewsclient.c
index 4db6bcfc2..fa3c3e346 100644
--- a/src/modules/gnome-online-accounts/goaewsclient.c
+++ b/src/modules/gnome-online-accounts/goaewsclient.c
@@ -378,6 +378,34 @@ ews_post_restarted_cb (SoupMessage *msg,
                buf_content, buf_size);
 }
 
+static gboolean
+go_ews_client_accept_certificate_cb (GTlsConnection *conn,
+                                    GTlsCertificate *peer_cert,
+                                    GTlsCertificateFlags errors,
+                                    gpointer user_data)
+{
+       /* As much as EDS is interested, any certificate error during
+          autodiscover is ignored, because it had been allowed during
+          the GOA account creation. */
+
+       return TRUE;
+}
+
+static void
+goa_ews_client_network_event_cb (SoupMessage *msg,
+                                GSocketClientEvent event,
+                                GIOStream *connection,
+                                gpointer user_data)
+{
+       /* It's either a GTlsConnection or a GTcpConnection */
+       if (event == G_SOCKET_CLIENT_TLS_HANDSHAKING &&
+           G_IS_TLS_CONNECTION (connection)) {
+               g_signal_connect (
+                       G_TLS_CONNECTION (connection), "accept-certificate",
+                       G_CALLBACK (go_ews_client_accept_certificate_cb), NULL);
+       }
+}
+
 static SoupMessage *
 ews_create_msg_for_url (const gchar *url,
                         xmlOutputBuffer *buf)
@@ -390,6 +418,9 @@ ews_create_msg_for_url (const gchar *url,
        soup_message_headers_append (
                msg->request_headers, "User-Agent", "libews/0.1");
 
+       g_signal_connect (msg, "network-event",
+               G_CALLBACK (goa_ews_client_network_event_cb), NULL);
+
        if (buf != NULL) {
                buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
                soup_message_set_request (


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]