Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/common
In directory sunsite.dk:/tmp/cvs-serv28513/src/common
Modified Files:
Tag: gtk2
ssl_certificate.c
Log Message:
2006-12-09 [colin] 2.6.1cvs13
* manual/advanced.xml
* src/prefs_common.c
* src/prefs_common.h
* src/common/ssl_certificate.c
Add a new hidden preference, 'unsafe_ssl_certs',
which allows to store multiple certificates per
server/port. This is disabled by default because
it's less secure (presenting a new certificate
instead of a changed one raises less alarms).
This will cause Claws to ask about an unknown
certificate for people who have used 2.6.1cvs8
or greater.
Index: ssl_certificate.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/common/ssl_certificate.c,v
retrieving revision 1.4.2.14
retrieving revision 1.4.2.15
diff -u -d -r1.4.2.14 -r1.4.2.15
--- ssl_certificate.c 2006/12/06 07:24:40 1.4.2.14
+++ ssl_certificate.c 2006/12/09 22:02:32 1.4.2.15
@@ -36,6 +36,20 @@
static GHashTable *warned_expired = NULL;
+gboolean prefs_common_unsafe_ssl_certs(void);
+
+static gchar *get_certificate_path(const gchar *host, const gchar *port, const gchar *fp)
+{
+ if (fp != NULL && prefs_common_unsafe_ssl_certs())
+ return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "certs", G_DIR_SEPARATOR_S,
+ host, ".", port, ".", fp, ".cert", NULL);
+ else
+ return g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ "certs", G_DIR_SEPARATOR_S,
+ host, ".", port, ".cert", NULL);
+}
+
static SSLCertificate *ssl_certificate_new_lookup(X509 *x509_cert, gchar *host, gushort port, gboolean lookup);
/* from Courier */
@@ -162,9 +176,7 @@
g_free(file);
port = g_strdup_printf("%d", cert->port);
- file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- cert->host, ".", port, ".", cert->fingerprint, ".cert", NULL);
+ file = get_certificate_path(cert->host, port, cert->fingerprint);
g_free(port);
fp = g_fopen(file, "wb");
@@ -278,9 +290,7 @@
gchar *buf;
gchar *file;
buf = g_strdup_printf("%d", cert->port);
- file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- cert->host, ".", buf, ".", cert->fingerprint, ".cert", NULL);
+ file = get_certificate_path(cert->host, buf, cert->fingerprint);
g_unlink (file);
g_free(file);
g_free(buf);
@@ -309,17 +319,13 @@
buf = g_strdup_printf("%d", port);
if (fingerprint != NULL) {
- file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- fqdn_host, ".", buf, ".", fingerprint, ".cert", NULL);
+ file = get_certificate_path(fqdn_host, buf, fingerprint);
fp = g_fopen(file, "rb");
}
if (fp == NULL) {
/* see if we have the old one */
g_free(file);
- file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- fqdn_host, ".", buf, ".cert", NULL);
+ file = get_certificate_path(fqdn_host, buf, NULL);
fp = g_fopen(file, "rb");
if (fp)
@@ -340,13 +346,10 @@
g_free(file);
if (must_rename) {
- gchar *old = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- fqdn_host, ".", buf, ".cert", NULL);
- gchar *new = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
- "certs", G_DIR_SEPARATOR_S,
- fqdn_host, ".", buf, ".", fingerprint, ".cert", NULL);
- move_file(old, new, TRUE);
+ gchar *old = get_certificate_path(fqdn_host, buf, NULL);
+ gchar *new = get_certificate_path(fqdn_host, buf, fingerprint);
+ if (strcmp(old, new))
+ move_file(old, new, TRUE);
g_free(old);
g_free(new);
}
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.