comparison libpurple/certificate.c @ 19507:7086c311867a

merge of 'db94e3dde2f5edb422e7d7c1ec30474e2000997c' and 'f655557cb302f81ab02279d4c79a097d8028c5b7'
author William Ehlhardt <williamehlhardt@gmail.com>
date Tue, 28 Aug 2007 03:34:06 +0000
parents d5ecaf5bce93
children b62683f4120d
comparison
equal deleted inserted replaced
19506:c3405700c2fe 19507:7086c311867a
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */ 27 */
28 28
29 #include <glib.h> 29 #include <glib.h>
30 30
31 #include "internal.h"
31 #include "certificate.h" 32 #include "certificate.h"
32 #include "debug.h" 33 #include "debug.h"
33 #include "internal.h"
34 #include "request.h" 34 #include "request.h"
35 #include "signals.h" 35 #include "signals.h"
36 #include "util.h" 36 #include "util.h"
37 37
38 /** List holding pointers to all registered certificate schemes */ 38 /** List holding pointers to all registered certificate schemes */
668 return FALSE; 668 return FALSE;
669 } 669 }
670 670
671 /* Attempt to point at the appropriate system path */ 671 /* Attempt to point at the appropriate system path */
672 if (NULL == x509_ca_syspath) { 672 if (NULL == x509_ca_syspath) {
673 #ifdef _WIN32
674 x509_ca_syspath = g_build_filename(DATADIR,
675 "ca-certs", NULL);
676 #else
673 x509_ca_syspath = g_build_filename(DATADIR, 677 x509_ca_syspath = g_build_filename(DATADIR,
674 "purple", "ca-certs", NULL); 678 "purple", "ca-certs", NULL);
679 #endif
675 } 680 }
676 681
677 /* Populate the certificates pool from the system path */ 682 /* Populate the certificates pool from the system path */
678 certdir = g_dir_open(x509_ca_syspath, 0, NULL); 683 certdir = g_dir_open(x509_ca_syspath, 0, NULL);
679 g_return_val_if_fail(certdir, FALSE); 684 g_return_val_if_fail(certdir, FALSE);
1769 gchar *sha_asc; 1774 gchar *sha_asc;
1770 GByteArray *sha_bin; 1775 GByteArray *sha_bin;
1771 gchar *cn; 1776 gchar *cn;
1772 time_t activation, expiration; 1777 time_t activation, expiration;
1773 /* Length of these buffers is dictated by 'man ctime_r' */ 1778 /* Length of these buffers is dictated by 'man ctime_r' */
1774 gchar activ_str[26], expir_str[26]; 1779 gchar *activ_str, *expir_str;
1775 gchar *secondary; 1780 gchar *secondary;
1776 1781
1777 /* Pull out the SHA1 checksum */ 1782 /* Pull out the SHA1 checksum */
1778 sha_bin = purple_certificate_get_fingerprint_sha1(crt); 1783 sha_bin = purple_certificate_get_fingerprint_sha1(crt);
1779 /* Now decode it for display */ 1784 /* Now decode it for display */
1786 1791
1787 /* Get the certificate times */ 1792 /* Get the certificate times */
1788 /* TODO: Check the times against localtime */ 1793 /* TODO: Check the times against localtime */
1789 /* TODO: errorcheck? */ 1794 /* TODO: errorcheck? */
1790 g_assert(purple_certificate_get_times(crt, &activation, &expiration)); 1795 g_assert(purple_certificate_get_times(crt, &activation, &expiration));
1791 ctime_r(&activation, activ_str); 1796 activ_str = g_strdup(ctime(&activation));
1792 ctime_r(&expiration, expir_str); 1797 expir_str = g_strdup(ctime(&expiration));
1793 1798
1794 /* Make messages */ 1799 /* Make messages */
1795 secondary = g_strdup_printf(_("Common name: %s\n\n" 1800 secondary = g_strdup_printf(_("Common name: %s\n\n"
1796 "Fingerprint (SHA1): %s\n\n" 1801 "Fingerprint (SHA1): %s\n\n"
1797 "Activation date: %s\n" 1802 "Activation date: %s\n"
1798 "Expiration date: %s\n"), 1803 "Expiration date: %s\n"),
1799 cn, sha_asc, activ_str, expir_str); 1804 cn, sha_asc, activ_str, expir_str);
1800 1805
1801 /* Make a semi-pretty display */ 1806 /* Make a semi-pretty display */
1802 purple_notify_info( 1807 purple_notify_info(
1803 NULL, /* TODO: Find what the handle ought to be */ 1808 NULL, /* TODO: Find what the handle ought to be */
1804 _("Certificate Information"), 1809 _("Certificate Information"),
1805 "", 1810 "",
1806 secondary); 1811 secondary);
1807 1812
1808 /* Cleanup */ 1813 /* Cleanup */
1809 g_free(cn); 1814 g_free(cn);
1810 g_free(secondary); 1815 g_free(secondary);
1811 g_free(sha_asc); 1816 g_free(sha_asc);
1817 g_free(activ_str);
1818 g_free(expir_str);
1812 g_byte_array_free(sha_bin, TRUE); 1819 g_byte_array_free(sha_bin, TRUE);
1813 } 1820 }
1814 1821
1815 1822
1816 1823