[evolution-data-server/camel-socks-proxy] Factor out function to rehandshake SSL



commit ee8fdcc0f1c0a83efa0ea91002185e107e03a915
Author: Federico Mena Quintero <federico novell com>
Date:   Wed Jun 2 15:02:23 2010 -0500

    Factor out function to rehandshake SSL
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 camel/camel-tcp-stream-ssl.c |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 818f303..132c977 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -290,6 +290,22 @@ set_errno (gint code)
 	}
 }
 
+static gboolean
+rehandshake_ssl (PRFileDesc *fd)
+{
+	if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
+		set_errno (PR_GetError ());
+		return FALSE;
+	}
+
+	if (SSL_ForceHandshake (fd) == SECFailure) {
+		set_errno (PR_GetError ());
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 /**
  * camel_tcp_stream_ssl_enable_ssl:
  * @ssl: a #CamelTcpStreamSSL object
@@ -313,15 +329,8 @@ camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *ssl)
 
 		ssl->priv->sockfd = fd;
 
-		if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
-			set_errno (PR_GetError ());
+		if (!rehandshake_ssl (fd))
 			return -1;
-		}
-
-		if (SSL_ForceHandshake (fd) == SECFailure) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
 	}
 
 	ssl->priv->ssl_mode = TRUE;
@@ -1328,16 +1337,8 @@ connect_to_socks4_proxy (CamelTcpStreamSSL *ssl, const gchar *proxy_host, gint p
 			d (g_print ("  could not enable SSL\n"));
 			goto error;
 		} else {
-			d (g_print ("  SSL_ResetHandshake\n"));
-			if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
-				set_errno (PR_GetError ());
-				d (g_print ("  failed\n"));
-				goto error;
-			}
-
-			d (g_print ("  SSL_ForceHandshake\n"));
-			if (SSL_ForceHandshake (fd) == SECFailure) {
-				set_errno (PR_GetError ());
+			d (g_print ("  re-handshaking SSL\n"));
+			if (!rehandshake_ssl (fd)) {
 				d (g_print ("  failed\n"));
 				goto error;
 			}



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