CVS: sylpheedclaws/sylpheed-claws/src ssl_manager.c,1.3.2.23,1.3.2.24

[email protected]
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src
In directory sunsite.dk:/tmp/cvs-serv5089/src

Modified Files:
      Tag: gtk2
	ssl_manager.c 
Log Message:
2006-12-06 [colin]	2.6.1cvs8

	* src/ssl_manager.c
	* src/common/ssl_certificate.c
	* src/common/ssl_certificate.h
		Handle multiple certificates per host/port

Index: ssl_manager.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/ssl_manager.c,v
retrieving revision 1.3.2.23
retrieving revision 1.3.2.24
diff -u -d -r1.3.2.23 -r1.3.2.24
--- ssl_manager.c	2006/11/14 07:26:41	1.3.2.23
+++ ssl_manager.c	2006/12/06 07:24:39	1.3.2.24
@@ -211,16 +211,24 @@
 static char *get_server(char *str)
 {
 	char *ret = NULL, *tmp = g_strdup(str);
-	char *first_pos = NULL, *last_pos = NULL, *previous_pos = NULL;
+	char *first_pos = NULL, *last_pos = NULL;
+	char *previous_pos = NULL, *pre_previous_pos = NULL;
 	int previous_dot_pos;
 
+	if (!strchr(tmp, ':')) {
+		/* no fingerprint */
+		if (strstr(tmp, ".cert"))
+			*(strstr(tmp, ".cert")+1) = '.';
+	}
+
 	first_pos = tmp;
 	while (tmp && (tmp = strstr(tmp,".")) != NULL) {
 		tmp++;
+		pre_previous_pos = previous_pos;
 		previous_pos = last_pos;
 		last_pos = tmp;
 	}
-	previous_dot_pos = (previous_pos - first_pos);
+	previous_dot_pos = (pre_previous_pos - first_pos);
 	if (previous_dot_pos - 1 > 0)
 		ret = g_strndup(first_pos, previous_dot_pos - 1);
 	else 
@@ -232,8 +240,41 @@
 static char *get_port(char *str)
 {
 	char *ret = NULL, *tmp = g_strdup(str);
+	char *last_pos = NULL;
+	char *previous_pos = NULL, *pre_previous_pos = NULL;
+
+	if (!strchr(tmp, ':')) {
+		/* no fingerprint */
+		if (strstr(tmp, ".cert"))
+			*(strstr(tmp, ".cert")+1) = '.';
+	}
+
+	while (tmp && (tmp = strstr(tmp,".")) != NULL) {
+		tmp++;
+		pre_previous_pos = previous_pos;
+		previous_pos = last_pos;
+		last_pos = tmp;
+	}
+	if (previous_pos && pre_previous_pos && (int)(previous_pos - pre_previous_pos - 1) > 0)
+		ret = g_strndup(pre_previous_pos, (int)(previous_pos - pre_previous_pos - 1));
+	else
+		ret = g_strdup("0");
+	g_free(tmp);
+	return ret;
+	
+}
+
+static char *get_fingerprint(char *str)
+{
+	char *ret = NULL, *tmp = g_strdup(str);
 	char *previous_pos = NULL, *last_pos = NULL;
 
+	if (!strchr(tmp, ':')) {
+		/* no fingerprint */
+		if (strstr(tmp, ".cert"))
+			*(strstr(tmp, ".cert")+1) = '.';
+	}
+
 	while (tmp && (tmp = strstr(tmp,".")) != NULL) {
 		tmp++;
 		previous_pos = last_pos;
@@ -242,7 +283,7 @@
 	if (last_pos && previous_pos && (int)(last_pos - previous_pos - 1) > 0)
 		ret = g_strndup(previous_pos, (int)(last_pos - previous_pos - 1));
 	else
-		ret = g_strdup("0");
+		ret = NULL;
 	g_free(tmp);
 	return ret;
 	
@@ -297,7 +338,7 @@
 	}
 	
 	while ((d = readdir(dir)) != NULL) {
-		gchar *server, *port;
+		gchar *server, *port, *fp;
 		SSLCertificate *cert;
 
 		if(!strstr(d->d_name, ".cert")) 
@@ -305,15 +346,16 @@
 
 		server = get_server(d->d_name);
 		port = get_port(d->d_name);
-		
-		
-		cert = ssl_certificate_find_lookup(server, atoi(port), FALSE);
+		fp = get_fingerprint(d->d_name);
 		
+		cert = ssl_certificate_find_lookup(server, atoi(port), fp, FALSE);
+
 		ssl_manager_list_view_insert_cert(manager.certlist, NULL, 
 						  server, port, cert);
 		
 		g_free(server);
 		g_free(port);
+		g_free(fp);
 		row++;
 	}
 	closedir(dir);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.