RSSyl: Allow giving custom CA cert file to libfeed
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 17 Jun 2015 11:47:01 +0000 (13:47 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 17 Jun 2015 11:47:01 +0000 (13:47 +0200)
src/plugins/rssyl/libfeed/feed.c
src/plugins/rssyl/libfeed/feed.h

index cd507049d22b09b4cf72d8ac40aac0fc26086972..1ddeb44445ede4a6ea9d2da6f363f820dd3002fb 100644 (file)
@@ -52,6 +52,9 @@ Feed *feed_new(gchar *url)
        feed->fetcherr = NULL;
        feed->cookies_path = NULL;
 
+       feed->ssl_verify_peer = TRUE;
+       feed->cacert_file = NULL;
+
        return feed;
 }
 
@@ -90,6 +93,7 @@ void feed_free(Feed *feed)
        g_free(feed->link);
        g_free(feed->fetcherr);
        g_free(feed->cookies_path);
+       g_free(feed->cacert_file);
 
        if( feed->items != NULL ) {
                g_slist_foreach(feed->items, _free_items, NULL);
@@ -302,6 +306,8 @@ guint feed_update(Feed *feed, time_t last_update)
        if (feed->ssl_verify_peer == FALSE) {
                curl_easy_setopt(eh, CURLOPT_SSL_VERIFYPEER, 0);
                curl_easy_setopt(eh, CURLOPT_SSL_VERIFYHOST, 0);
+               if (feed->cacert_file != NULL)
+                       curl_easy_setopt(eh, CURLOPT_CAINFO, feed->cacert_file);
        }
 #endif
 
@@ -411,3 +417,21 @@ void feed_set_ssl_verify_peer(Feed *feed, gboolean ssl_verify_peer)
        g_return_if_fail(feed != NULL);
        feed->ssl_verify_peer = ssl_verify_peer;
 }
+
+gchar *feed_get_cacert_file(Feed *feed)
+{
+       g_return_val_if_fail(feed != NULL, NULL);
+       return feed->cacert_file;
+}
+
+void feed_set_cacert_file(Feed *feed, gchar *path)
+{
+       g_return_if_fail(feed != NULL);
+
+       if( feed->cacert_file != NULL ) {
+               g_free(feed->cacert_file);
+               feed->cacert_file = NULL;
+       }
+
+       feed->cacert_file = (path != NULL ? g_strdup(path) : NULL);
+}
index 5abde34bf2b9321d437da0aaf0fc65d4e472ec20..18c18016adc8c07136214ff9ea286e506eb2d7bd 100644 (file)
@@ -58,6 +58,7 @@ struct _Feed {
        gchar *fetcherr;
        gchar *cookies_path;
        gboolean ssl_verify_peer;
+       gchar *cacert_file;
 
        GSList *items;
 };
@@ -115,6 +116,9 @@ void feed_set_cookies_path(Feed *feed, gchar *path);
 gboolean feed_get_ssl_verify_peer(Feed *feed);
 void feed_set_ssl_verify_peer(Feed *feed, gboolean ssl_verify_peer);
 
+gchar *feed_get_cacert_file(Feed *feed);
+void feed_set_cacert_file(Feed *feed, gchar *path);
+
 gint feed_n_items(Feed *feed);
 FeedItem *feed_nth_item(Feed *feed, guint n);