aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2010-09-08 22:57:29 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2010-09-08 22:57:29 +0800
commit127bd46e7c03eb95501e65836c301b1bbb6c8c5d (patch)
treef8b85053df3478b7cbe800a44f68b14449e808a6
parent82fa83288652fb6b856b442145b10791941f3113 (diff)
downloadgsoc2013-empathy-127bd46e7c03eb95501e65836c301b1bbb6c8c5d.tar.gz
gsoc2013-empathy-127bd46e7c03eb95501e65836c301b1bbb6c8c5d.tar.zst
gsoc2013-empathy-127bd46e7c03eb95501e65836c301b1bbb6c8c5d.zip
Use better names for saving the certificates
-rw-r--r--libempathy/empathy-tls-certificate.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libempathy/empathy-tls-certificate.c b/libempathy/empathy-tls-certificate.c
index e2fc67614..f36887dcd 100644
--- a/libempathy/empathy-tls-certificate.c
+++ b/libempathy/empathy-tls-certificate.c
@@ -446,8 +446,9 @@ empathy_tls_certificate_store_ca (EmpathyTLSCertificate *self)
gnutls_datum_t datum = { NULL, 0 };
gsize exported_len;
guchar *exported_cert = NULL;
- gint res;
+ gint res, offset;
gchar *user_certs_dir = NULL, *filename = NULL, *path = NULL;
+ gchar *hostname = NULL;
GError *error = NULL;
EmpathyTLSCertificatePriv *priv = GET_PRIV (self);
@@ -489,6 +490,11 @@ empathy_tls_certificate_store_ca (EmpathyTLSCertificate *self)
goto out;
}
+ hostname = empathy_get_x509_certificate_hostname (cert);
+
+ if (hostname == NULL)
+ hostname = g_strdup ("ca");
+
gnutls_x509_crt_deinit (cert);
/* write the file */
@@ -505,13 +511,20 @@ empathy_tls_certificate_store_ca (EmpathyTLSCertificate *self)
goto out;
}
+ offset = 0;
+
do
{
g_free (path);
- filename = g_strdup_printf ("cert-%p", cert);
+ if (offset == 0)
+ filename = g_strdup_printf ("cert-%s", hostname);
+ else
+ filename = g_strdup_printf ("cert-%s-%d", hostname, offset);
+
path = g_build_filename (user_certs_dir, filename, NULL);
+ offset++;
g_free (filename);
}
while (g_file_test (path, G_FILE_TEST_EXISTS));
@@ -533,4 +546,5 @@ empathy_tls_certificate_store_ca (EmpathyTLSCertificate *self)
g_free (path);
g_free (exported_cert);
g_free (user_certs_dir);
+ g_free (hostname);
}