summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Lynch <rusty.lynch@intel.com>2013-05-19 09:51:07 -0700
committerRusty Lynch <rusty.lynch@intel.com>2013-05-19 09:51:07 -0700
commite301db193aa43dff8391f7739ab3bbfa33a09fa0 (patch)
treec7bd65a6bcdbfcce844b5f90050b83d4136d5811
parent121846ec1164560b140f4993ae1f019fcf61bb5e (diff)
downloadlibsoup-e301db193aa43dff8391f7739ab3bbfa33a09fa0.tar.gz
libsoup-e301db193aa43dff8391f7739ab3bbfa33a09fa0.tar.bz2
libsoup-e301db193aa43dff8391f7739ab3bbfa33a09fa0.zip
Add SOUP_SESSION_CERTIFICATE_PATH support
Forward part the certificate path setting support found in the Tizen 2.1 libsoup package. This is needed by webkit-efl
-rw-r--r--libsoup/soup-session.c57
-rw-r--r--libsoup/soup-session.h1
2 files changed, 58 insertions, 0 deletions
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 186d57ad..59583b34 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -127,6 +127,8 @@ typedef struct {
char **http_aliases, **https_aliases;
GHashTable *request_types;
+
+ char *certificate_path;
} SoupSessionPrivate;
#define SOUP_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_SESSION, SoupSessionPrivate))
@@ -195,6 +197,7 @@ enum {
PROP_HTTP_ALIASES,
PROP_HTTPS_ALIASES,
PROP_LOCAL_ADDRESS,
+ PROP_CERTIFICATE_PATH,
LAST_PROP
};
@@ -343,6 +346,7 @@ soup_session_finalize (GObject *object)
g_free (priv->https_aliases);
g_hash_table_destroy (priv->request_types);
+ g_free (priv->certificate_path);
G_OBJECT_CLASS (soup_session_parent_class)->finalize (object);
}
@@ -680,6 +684,13 @@ soup_session_set_property (GObject *object, guint prop_id,
case PROP_HTTPS_ALIASES:
set_aliases (&priv->https_aliases, g_value_get_boxed (value));
break;
+ case PROP_CERTIFICATE_PATH:
+ if (priv->certificate_path) {
+ g_free (priv->certificate_path);
+ priv->certificate_path = NULL;
+ }
+ priv->certificate_path = g_strdup (g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -765,6 +776,9 @@ soup_session_get_property (GObject *object, guint prop_id,
case PROP_HTTPS_ALIASES:
g_value_set_boxed (value, priv->https_aliases);
break;
+ case PROP_CERTIFICATE_PATH:
+ g_value_set_string (value, priv->certificate_path);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1779,6 +1793,33 @@ get_connection (SoupMessageQueueItem *item, gboolean *should_cleanup)
}
}
+static void
+soup_session_set_certificate_file(SoupSession *session, SoupMessageQueueItem *item)
+{
+ SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
+ SoupURI *uri;
+
+ if (!priv->certificate_path)
+ return;
+
+ uri = soup_message_get_uri (item->msg);
+
+ if (uri_is_https (priv, uri) && (!priv->tlsdb)) {
+ GError* error = NULL;
+ GTlsDatabase* tlsdb = g_tls_file_database_new(priv->certificate_path, &error);
+ if (!error && tlsdb) {
+ set_tlsdb (session, tlsdb);
+ }
+
+ if (tlsdb)
+ g_object_unref (tlsdb);
+ if (priv->certificate_path) {
+ g_free (priv->certificate_path);
+ priv->certificate_path = NULL;
+ }
+ }
+}
+
void
soup_session_process_queue_item (SoupSession *session,
SoupMessageQueueItem *item,
@@ -1793,6 +1834,7 @@ soup_session_process_queue_item (SoupSession *session,
switch (item->state) {
case SOUP_MESSAGE_STARTING:
+ soup_session_set_certificate_file(session, item);
if (!get_connection (item, should_cleanup))
return;
break;
@@ -3575,6 +3617,21 @@ soup_session_class_init (SoupSessionClass *session_class)
"Address of local end of socket",
SOUP_TYPE_ADDRESS,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * SOUP_SESSION_CERTIFICATE_PATH
+ * SoupSession:certificate-path:
+ *
+ * Set the certificate path for soup session
+ *
+ */
+ g_object_class_install_property (
+ object_class, PROP_CERTIFICATE_PATH,
+ g_param_spec_string (SOUP_SESSION_CERTIFICATE_PATH,
+ "certificate file path",
+ "Set the ca-certificate.crt file path",
+ NULL,
+ G_PARAM_READWRITE));
}
diff --git a/libsoup/soup-session.h b/libsoup/soup-session.h
index 67a59eaa..d22081df 100644
--- a/libsoup/soup-session.h
+++ b/libsoup/soup-session.h
@@ -82,6 +82,7 @@ GType soup_session_get_type (void);
#define SOUP_SESSION_REMOVE_FEATURE_BY_TYPE "remove-feature-by-type"
#define SOUP_SESSION_HTTP_ALIASES "http-aliases"
#define SOUP_SESSION_HTTPS_ALIASES "https-aliases"
+#define SOUP_SESSION_CERTIFICATE_PATH "certificate-path"
SOUP_AVAILABLE_IN_2_42
SoupSession *soup_session_new (void);