[evolution-data-server] Enable SSL on the socket after we are proxied



commit 35c4e784959bcb0e5ce6833f6480a3cad82bc25d
Author: Federico Mena Quintero <federico novell com>
Date:   Thu May 27 14:56:12 2010 -0500

    Enable SSL on the socket after we are proxied
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-tcp-stream-ssl.c |   46 +++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 4424da1..17cad0a 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -952,6 +952,27 @@ enable_ssl (CamelTcpStreamSSL *ssl, PRFileDesc *fd)
 	return ssl_fd;
 }
 
+static PRFileDesc *
+enable_ssl_or_close_fd (CamelTcpStreamSSL *ssl, PRFileDesc *fd)
+{
+	PRFileDesc *ssl_fd;
+
+	ssl_fd = enable_ssl (ssl, fd);
+	if (ssl_fd == NULL) {
+		gint errnosave;
+
+		set_errno (PR_GetError ());
+		errnosave = errno;
+		PR_Shutdown (fd, PR_SHUTDOWN_BOTH);
+		PR_Close (fd);
+		errno = errnosave;
+
+		return NULL;
+	}
+
+	return ssl_fd;
+}
+
 static gint
 sockaddr_to_praddr(struct sockaddr *s, gint len, PRNetAddr *addr)
 {
@@ -1011,22 +1032,9 @@ tcp_socket_ssl_connect (CamelTcpStream *stream, struct addrinfo *host, gboolean
 	}
 
 	if (possibly_use_ssl && ssl->priv->ssl_mode) {
-		PRFileDesc *ssl_fd;
-
-		ssl_fd = enable_ssl (ssl, fd);
-		if (ssl_fd == NULL) {
-			gint errnosave;
-
-			set_errno (PR_GetError ());
-			errnosave = errno;
-			PR_Shutdown (fd, PR_SHUTDOWN_BOTH);
-			PR_Close (fd);
-			errno = errnosave;
-
+		fd = enable_ssl_or_close_fd (ssl, fd);
+		if (!fd)
 			return NULL;
-		}
-
-		fd = ssl_fd;
 	}
 
 	cancel_fd = camel_operation_cancel_prfd(NULL);
@@ -1135,7 +1143,13 @@ connect_to_socks4_proxy (CamelTcpStreamSSL *ssl, const gchar *proxy_host, gint p
 	      && reply[1] != 90))	/* 90 means "request granted" */
 		goto error;
 
-	/* FMQ: turn on SSL on this fd */
+	/* We are now proxied we are ready to send "normal" data through the socket */
+
+	if (ssl->priv->ssl_mode) {
+		fd = enable_ssl_or_close_fd (ssl, fd);
+		if (!fd)
+			goto error;
+	}
 
 	goto out;
 



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