changeset 24653:c6772d61af1f

Use purple_proxy_connect + purple_ssl_connect_with_host_fd() to hopefully silence warnings (I get more warnings because I don't have the certificate in a trusted store)
author Paul Aurich <paul@darkrain42.org>
date Thu, 11 Dec 2008 08:06:23 +0000
parents d3f47707e260
children d265a11c6446
files libpurple/protocols/oscar/flap_connection.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h
diffstat 3 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/flap_connection.c	Thu Dec 11 07:14:50 2008 +0000
+++ b/libpurple/protocols/oscar/flap_connection.c	Thu Dec 11 08:06:23 2008 +0000
@@ -476,6 +476,7 @@
 
 	g_free(conn->error_message);
 	g_free(conn->cookie);
+	g_free(conn->ssl_cert_cn);
 
 	/*
 	 * Free conn->internal, if necessary
--- a/libpurple/protocols/oscar/oscar.c	Thu Dec 11 07:14:50 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Dec 11 08:06:23 2008 +0000
@@ -1227,6 +1227,32 @@
 }
 
 static void
+ssl_proxy_conn_established_cb(gpointer data, gint source, const gchar *error_message)
+{
+	OscarData *od;
+	PurpleConnection *gc;
+	PurpleAccount *account;
+	FlapConnection *conn;
+
+	conn = data;
+	od = conn->od;
+	gc = od->gc;
+	account = purple_connection_get_account(gc);
+
+	conn->connect_data = NULL;
+
+	if (source < 0)
+	{
+		connection_common_error_cb(conn, error_message);
+		return;
+	}
+
+	conn->gsc = purple_ssl_connect_with_host_fd(account, source,
+			ssl_connection_established_cb, ssl_connection_error_cb,
+			conn->ssl_cert_cn, conn);
+}
+
+static void
 flap_connection_established_bos(OscarData *od, FlapConnection *conn)
 {
 	PurpleConnection *gc = od->gc;
@@ -1992,9 +2018,13 @@
 
 	if (redir->use_ssl)
 	{
-		newconn->gsc = purple_ssl_connect(account, host, port,
-				ssl_connection_established_cb, ssl_connection_error_cb,
-				newconn);
+		/* FIXME: It should be possible to specify a certificate common name
+		 * distinct from the host we're passing to purple_ssl_connect. The
+		 * way to work around that is to use purple_proxy_connect +
+		 * purple_ssl_connect_with_host_fd */
+		newconn->ssl_cert_cn = g_strdup(redir->ssl_cert_cn);
+		newconn->connect_data = purple_proxy_connect(NULL, account, host, port,
+				ssl_proxy_conn_established_cb, newconn);
 	}
 	else
 	{
--- a/libpurple/protocols/oscar/oscar.h	Thu Dec 11 07:14:50 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Thu Dec 11 08:06:23 2008 +0000
@@ -417,6 +417,7 @@
 	guint16 cookielen;
 	guint8 *cookie;
 	gpointer new_conn_data;
+	gchar *ssl_cert_cn;
 
 	int fd;
 	PurpleSslConnection *gsc;