comparison libpurple/plugins/ssl/ssl-gnutls.c @ 19067:6c0aad79c4c5

- Change the internal structure of activation/expiration times to match the "NSS way", which is already how the libpurple public interface works - Change ssl-gnutls to match the above
author William Ehlhardt <williamehlhardt@gmail.com>
date Fri, 03 Aug 2007 06:12:42 +0000
parents fcca10d0ac7d
children daa68185a018
comparison
equal deleted inserted replaced
19066:b631b409a515 19067:6c0aad79c4c5
780 } else { 780 } else {
781 return FALSE; 781 return FALSE;
782 } 782 }
783 } 783 }
784 784
785 static time_t 785 static gboolean
786 x509_activation (PurpleCertificate *crt) 786 x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration)
787 { 787 {
788 gnutls_x509_crt_t crt_dat; 788 gnutls_x509_crt_t crt_dat;
789 789 /* GnuTLS time functions return this on error */
790 g_assert(crt); 790 const time_t errval = (time_t) (-1);
791 g_assert(crt->scheme == &x509_gnutls); 791
792
793 g_return_val_if_fail(crt, FALSE);
794 g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE);
792 795
793 crt_dat = X509_GET_GNUTLS_DATA(crt); 796 crt_dat = X509_GET_GNUTLS_DATA(crt);
794 797
795 /* TODO: Errorcheck this? */ 798 if (activation) {
796 return gnutls_x509_crt_get_activation_time(crt_dat); 799 *activation = gnutls_x509_crt_get_activation_time(crt_dat);
797 } 800 }
798 801 if (expiration) {
799 static time_t 802 *expiration = gnutls_x509_crt_get_expiration_time(crt_dat);
800 x509_expiration (PurpleCertificate *crt) 803 }
801 { 804
802 gnutls_x509_crt_t crt_dat; 805 if (*activation == errval || *expiration == errval) {
803 806 return FALSE;
804 g_assert(crt); 807 }
805 g_assert(crt->scheme == &x509_gnutls); 808
806 809 return TRUE;
807 crt_dat = X509_GET_GNUTLS_DATA(crt);
808
809 /* TODO: Errorcheck this? */
810 return gnutls_x509_crt_get_expiration_time(crt_dat);
811 } 810 }
812 811
813 /* X.509 certificate operations provided by this plugin */ 812 /* X.509 certificate operations provided by this plugin */
814 /* TODO: Flesh this out! */ 813 /* TODO: Flesh this out! */
815 static PurpleCertificateScheme x509_gnutls = { 814 static PurpleCertificateScheme x509_gnutls = {
822 x509_sha1sum, /* SHA1 fingerprint */ 821 x509_sha1sum, /* SHA1 fingerprint */
823 NULL, /* Unique ID */ 822 NULL, /* Unique ID */
824 NULL, /* Issuer Unique ID */ 823 NULL, /* Issuer Unique ID */
825 x509_common_name, /* Subject name */ 824 x509_common_name, /* Subject name */
826 x509_check_name, /* Check subject name */ 825 x509_check_name, /* Check subject name */
827 x509_activation, /* Activation time */ 826 x509_times /* Activation/Expiration time */
828 x509_expiration /* Expiration time */
829 }; 827 };
830 828
831 static PurpleSslOps ssl_ops = 829 static PurpleSslOps ssl_ops =
832 { 830 {
833 ssl_gnutls_init, 831 ssl_gnutls_init,