Mercurial > pidgin.yaz
comparison libpurple/certificate.c @ 19329:e93db0c87b26
- Add purple_certificate_display_x509
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Sat, 18 Aug 2007 05:54:49 +0000 |
parents | c28e1afe691b |
children | b65a23799dc2 |
comparison
equal
deleted
inserted
replaced
19328:8634792bdaad | 19329:e93db0c87b26 |
---|---|
1717 purple_debug_info("certificate", | 1717 purple_debug_info("certificate", |
1718 "CertificatePool %s unregistered\n", | 1718 "CertificatePool %s unregistered\n", |
1719 pool->name); | 1719 pool->name); |
1720 return TRUE; | 1720 return TRUE; |
1721 } | 1721 } |
1722 | |
1723 /****************************************************************************/ | |
1724 /* Scheme-specific functions */ | |
1725 /****************************************************************************/ | |
1726 | |
1727 void | |
1728 purple_certificate_display_x509(PurpleCertificate *crt) | |
1729 { | |
1730 gchar *sha_asc; | |
1731 GByteArray *sha_bin; | |
1732 gchar *cn; | |
1733 time_t activation, expiration; | |
1734 /* Length of these buffers is dictated by 'man ctime_r' */ | |
1735 gchar activ_str[26], expir_str[26]; | |
1736 gchar *title, *primary, *secondary; | |
1737 | |
1738 /* Pull out the SHA1 checksum */ | |
1739 sha_bin = purple_certificate_get_fingerprint_sha1(crt); | |
1740 /* Now decode it for display */ | |
1741 sha_asc = purple_base16_encode_chunked(sha_bin->data, | |
1742 sha_bin->len); | |
1743 | |
1744 /* Get the cert Common Name */ | |
1745 /* TODO: Will break on CA certs */ | |
1746 cn = purple_certificate_get_subject_name(crt); | |
1747 | |
1748 /* Get the certificate times */ | |
1749 /* TODO: Check the times against localtime */ | |
1750 /* TODO: errorcheck? */ | |
1751 g_assert(purple_certificate_get_times(crt, &activation, &expiration)); | |
1752 ctime_r(&activation, activ_str); | |
1753 ctime_r(&expiration, expir_str); | |
1754 | |
1755 /* Make messages */ | |
1756 title = g_strdup_printf(_("Certificate: %s"), cn); | |
1757 primary = NULL; | |
1758 secondary = g_strdup_printf(_("Common name: %s\n\n" | |
1759 "Fingerprint (SHA1): %s\n\n" | |
1760 "Activation date: %s\n" | |
1761 "Expiration date: %s\n"), | |
1762 cn, sha_asc, activ_str, expir_str); | |
1763 | |
1764 /* Make a semi-pretty display */ | |
1765 purple_notify_info( | |
1766 NULL, /* TODO: Find what the handle ought to be */ | |
1767 title, | |
1768 primary, | |
1769 secondary); | |
1770 | |
1771 /* Cleanup */ | |
1772 g_free(cn); | |
1773 g_free(title); | |
1774 g_free(primary); | |
1775 g_free(secondary); | |
1776 g_free(sha_asc); | |
1777 g_byte_array_free(sha_bin, TRUE); | |
1778 } | |
1779 | |
1780 | |
1781 | |
1782 |