ecore: add ecore_con_url_ssl_ca_set.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Mar 2011 09:15:24 +0000 (09:15 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 30 Mar 2011 09:15:24 +0000 (09:15 +0000)
patch by PnB <Poor.NewBie@gmail.com>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@58197 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

AUTHORS
ChangeLog
src/lib/ecore_con/Ecore_Con.h
src/lib/ecore_con/ecore_con_url.c

diff --git a/AUTHORS b/AUTHORS
index c8f7095..bf44cd4 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -38,3 +38,4 @@ Leif Middelschulte <leif.middelschulte@gmail.com>
 Mike McCormack <mj.mccormack@samsung.com>
 Sangho Park <gouache95@gmail.com>
 Jihoon Kim <jihoon48.kim@samsung.com> <imfine98@gmail.com>
+PnB <Poor.NewBie@gmail.com>
index c55bfe2..764e88c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,7 +12,7 @@
 
 2011-01-31  Carsten Haitzler (The Rasterman)
 
-        * Fix: ecore-evas CAN send "render done" messages even if not
+        * Fix ecore-evas CAN send "render done" messages even if not
         waiting for sync counter when using gl engine. new semi-sync
         mode to account for that.
 
@@ -47,7 +47,7 @@
 
        * Ecore_Win32: improve resize of windows and fix key up event for
        the 'space' key.
-       * Ecore_WinCE: do not erase a window background
+       * Ecore_WinCE do not erase a window background
 
 2011-02-21 Jihoon Kim
 
 
 2011-02-22  Carsten Haitzler (The Rasterman)
 
-        * Fix: ecore-file inotify fd would be duplicated in children
+        * Fix ecore-file inotify fd would be duplicated in children
         on fork. Have it detecti this on next monitor add and re-init the
         inotify fd and fd handler.
 
 2011-02-24 Vincent Torri
 
-       * Ecore_File: fix compilation when ecore_con and curl are not
+       * Ecore_File fix compilation when ecore_con and curl are not
        available
 
 2011-02-27 Jihoon Kim
 
 2011-03-23  Carsten Haitzler (The Rasterman)
 
-        * Fix: ecore-evas interceptor didn't handle override-redirect
+        * Fix ecore-evas interceptor didn't handle override-redirect
         windows correctly, expecting a feed-back event from x, which it didn't
         get.
 
 2011-03-23  Elixirious
 
-       * Fix: ecore_con_url_ftp_upload upload the file until the end.
+       * Fix ecore_con_url_ftp_upload upload the file until the end.
+
+2011-03-29  PnB
+
+       * Add ecore_con_url_ssl_ca_set to manually set a certificate authority.
 
index b8fbad8..692d6c5 100644 (file)
@@ -579,6 +579,8 @@ EAPI void              ecore_con_url_cookies_jar_write(Ecore_Con_Url *url_con);
 
 EAPI void              ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con,
                                                          Eina_Bool verify);
+EAPI int               ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con,
+                                                const char *ca_path);
 
 /**
  * @}
index 30fd317..5df6d98 100644 (file)
@@ -1416,7 +1416,7 @@ ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con,
  */
 EAPI void
 ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con,
-                              Eina_Bool      verify)
+                                 Eina_Bool      verify)
 {
 #ifdef HAVE_CURL
    if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
@@ -1440,6 +1440,55 @@ ecore_con_url_ssl_verify_peer_set(Ecore_Con_Url *url_con,
 }
 
 /**
+ * Set a custom CA to trust for SSL/TLS connections.
+ * 
+ * Specify the path of a file (in PEM format) containing one or more
+ * CA certificate(s) to use for the validation of the server certificate.
+ * 
+ * This function can also disable CA validation if @p ca_path is @c NULL.
+ * However, the server certificate still needs to be valid for the connection
+ * to succeed (i.e., the certificate must concern the server the
+ * connection is made to).
+ * 
+ * @param url_con Connection object that will use the custom CA.
+ * @param ca_path Path to a CA certificate(s) file or @c NULL to disable
+ *                CA validation.
+ * 
+ * @return  @c 0 on success. When cURL is used, non-zero return values
+ *          are equal to cURL error codes.
+ */
+EAPI int
+ecore_con_url_ssl_ca_set(Ecore_Con_Url *url_con, const char *ca_path)
+{
+   int res = -1;
+
+#ifdef HAVE_CURL
+   if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL))
+     {
+       ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_ssl_ca_set");
+             return -1;
+     }
+
+   if (url_con->active) return -1;
+   if (!url_con->url) return -1;
+   if (ca_path == NULL)
+     res = curl_easy_setopt(url_con->curl_easy, CURLOPT_SSL_VERIFYPEER, 0);
+   else
+     {
+       res = curl_easy_setopt(url_con->curl_easy, CURLOPT_SSL_VERIFYPEER, 1);
+       if (!res)
+         res = curl_easy_setopt(url_con->curl_easy, CURLOPT_CAINFO, ca_path);
+     }
+#else
+   (void)url_con;
+   (void)ca_path;
+#endif
+
+   return res;
+}
+
+
+/**
  * @}
  */