# HG changeset patch # User William Ehlhardt # Date 1183860631 0 # Node ID 986413850713988816c5dfbfd6c2b25f018170e9 # Parent 7fbd0a6ac8d6956526d783e332dc914069dffd7f - More skeletonizing for tls_cached logic. - Fixed memleak diff -r 7fbd0a6ac8d6 -r 986413850713 libpurple/certificate.c --- a/libpurple/certificate.c Sun Jul 08 02:01:57 2007 +0000 +++ b/libpurple/certificate.c Sun Jul 08 02:10:31 2007 +0000 @@ -433,6 +433,28 @@ static PurpleCertificateVerifier x509_tls_cached; static void +x509_tls_cached_unknown_peer(PurpleCertificateVerificationRequest *vrq) +{ + /* TODO: Prompt the user, etc. */ + + (vrq->cb)(PURPLE_CERTIFICATE_INVALID, vrq->cb_data); + /* Okay, we're done here */ + purple_certificate_verify_destroy(vrq); + return; +} + +static void +x509_tls_cached_peer_cert_changed(PurpleCertificateVerificationRequest *vrq) +{ + /* TODO: Prompt the user, etc. */ + + (vrq->cb)(PURPLE_CERTIFICATE_INVALID, vrq->cb_data); + /* Okay, we're done here */ + purple_certificate_verify_destroy(vrq); + return; +} + +static void x509_tls_cached_start_verify(PurpleCertificateVerificationRequest *vrq) { PurpleCertificate *peer_crt = (PurpleCertificate *) vrq->cert_chain->data; @@ -481,18 +503,13 @@ "Peer cert matched cached\n"); (vrq->cb)(PURPLE_CERTIFICATE_VALID, vrq->cb_data); - /* Okay, we're done here */ + /* vrq is now finished */ purple_certificate_verify_destroy(vrq); - return; } else { purple_debug_info("certificate/x509/tls_cached", "Peer cert did NOT match cached\n"); - /* TODO: Prompt the user, etc. */ - - (vrq->cb)(PURPLE_CERTIFICATE_INVALID, vrq->cb_data); - /* Okay, we're done here */ - purple_certificate_verify_destroy(vrq); - return; + /* vrq now becomes the problem of cert_changed */ + x509_tls_cached_peer_cert_changed(vrq); } purple_certificate_destroy(cached_crt); @@ -502,11 +519,8 @@ /* TODO: Prompt the user, etc. */ purple_debug_info("certificate/x509/tls_cached", "...Not in cache\n"); - - (vrq->cb)(PURPLE_CERTIFICATE_INVALID, vrq->cb_data); - /* Okay, we're done here */ - purple_certificate_verify_destroy(vrq); - return; + /* vrq now becomes the problem of unknown_peer */ + x509_tls_cached_unknown_peer(vrq); } }