# HG changeset patch # User Paul Aurich # Date 1247712396 0 # Node ID 199cf148cdf8a3811279e57367986dd1d540112f # Parent d677981cf97ed45a34f07151f179e86ebbfd04e3 Continue verification when we can't find a *cached* peer. Fixes #9664. This should be a fatal condition and not finding a cached certificate is *not* the same as "the certificate changed". diff -r d677981cf97e -r 199cf148cdf8 ChangeLog --- a/ChangeLog Thu Jul 16 02:20:40 2009 +0000 +++ b/ChangeLog Thu Jul 16 02:46:36 2009 +0000 @@ -35,6 +35,7 @@ from you on MSN. * Support sending an invite message to buddies when requesting authorization from them on MSN. + * Better handle corrupt certificates in the TLS Peers cache. AIM and ICQ: * Preliminary support for a new authentication scheme called diff -r d677981cf97e -r 199cf148cdf8 libpurple/certificate.c --- a/libpurple/certificate.c Thu Jul 16 02:20:40 2009 +0000 +++ b/libpurple/certificate.c Thu Jul 16 02:46:36 2009 +0000 @@ -1218,20 +1218,6 @@ } static void -x509_tls_cached_peer_cert_changed(PurpleCertificateVerificationRequest *vrq) -{ - /* TODO: Prompt the user, etc. */ - - purple_debug_info("certificate/x509/tls_cached", - "Certificate for %s does not match cached. " - "Auto-rejecting!\n", - vrq->subject_name); - - purple_certificate_verify_complete(vrq, PURPLE_CERTIFICATE_INVALID); - return; -} - -static void x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq); static void @@ -1254,12 +1240,11 @@ cached_crt = purple_certificate_pool_retrieve( tls_peers, vrq->subject_name); if ( !cached_crt ) { - purple_debug_error("certificate/x509/tls_cached", + purple_debug_warning("certificate/x509/tls_cached", "Lookup failed on cached certificate!\n" - "It was here just a second ago. Forwarding " - "to cert_changed.\n"); - /* vrq now becomes the problem of cert_changed */ - x509_tls_cached_peer_cert_changed(vrq); + "Falling back to full verification.\n"); + /* vrq now becomes the problem of unknown_peer */ + x509_tls_cached_unknown_peer(vrq); return; } diff -r d677981cf97e -r 199cf148cdf8 libpurple/plugins/ssl/ssl-nss.c --- a/libpurple/plugins/ssl/ssl-nss.c Thu Jul 16 02:20:40 2009 +0000 +++ b/libpurple/plugins/ssl/ssl-nss.c Thu Jul 16 02:46:36 2009 +0000 @@ -546,12 +546,12 @@ CERTCertificate *crt_dat; PurpleCertificate *crt; - g_return_val_if_fail(filename, NULL); + g_return_val_if_fail(filename != NULL, NULL); purple_debug_info("nss/x509", "Loading certificate from %s\n", filename); - + /* Load the raw data up */ if (!g_file_get_contents(filename, &rawcert, &len, @@ -560,12 +560,20 @@ return NULL; } + if (len == 0) { + purple_debug_error("nss/x509", + "Certificate file has no contents!\n"); + if (rawcert) + g_free(rawcert); + return NULL; + } + /* Decode the certificate */ crt_dat = CERT_DecodeCertFromPackage(rawcert, len); g_free(rawcert); - g_return_val_if_fail(crt_dat, NULL); - + g_return_val_if_fail(crt_dat != NULL, NULL); + crt = g_new0(PurpleCertificate, 1); crt->scheme = &x509_nss; crt->data = crt_dat;