Make a real SoupSSLCredentials type rather than just using gpointer
authorDan Winship <danw@src.gnome.org>
Mon, 16 Apr 2007 17:40:25 +0000 (17:40 +0000)
committerDan Winship <danw@src.gnome.org>
Mon, 16 Apr 2007 17:40:25 +0000 (17:40 +0000)
* libsoup/soup-ssl.h: Make a real SoupSSLCredentials type rather
than just using gpointer

* libsoup/soup-server.c (SoupServerPrivate): use it

* libsoup/soup-session.c (SoupSessionPrivate): use it

* libsoup/soup-gnutls.c: Use it, and consistently use "creds"
rather than "cred" as the abbreviation for "credentials".

* docs/reference/libsoup-sections.txt:
* docs/reference/tmpl/soup-misc.sgml:
* docs/reference/tmpl/soup-ssl.sgml: update

svn path=/trunk/; revision=924

ChangeLog
docs/reference/libsoup-sections.txt
docs/reference/tmpl/soup-misc.sgml
docs/reference/tmpl/soup-ssl.sgml
libsoup/soup-gnutls.c
libsoup/soup-server.c
libsoup/soup-session.c
libsoup/soup-ssl.h

index f75fb39..1125277 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-04-16  Dan Winship  <danw@novell.com>
+
+       * libsoup/soup-ssl.h: Make a real SoupSSLCredentials type rather
+       than just using gpointer
+
+       * libsoup/soup-server.c (SoupServerPrivate): use it
+
+       * libsoup/soup-session.c (SoupSessionPrivate): use it
+
+       * libsoup/soup-gnutls.c: Use it, and consistently use "creds"
+       rather than "cred" as the abbreviation for "credentials".
+
+       * docs/reference/libsoup-sections.txt:
+       * docs/reference/tmpl/soup-misc.sgml: 
+       * docs/reference/tmpl/soup-ssl.sgml: update
+       
 2007-03-29  Dan Winship  <danw@novell.com>
 
        * libsoup/soup-session-sync.c (queue_message): Implement this by
index 87c764a..78c59b0 100644 (file)
@@ -99,6 +99,10 @@ soup_message_io_in_progress
 soup_message_io_server
 soup_message_run_handlers
 soup_message_send_request_internal
+soup_message_get_auth
+soup_message_get_proxy_auth
+soup_message_set_auth
+soup_message_set_proxy_auth
 </SECTION>
 
 <SECTION>
@@ -526,6 +530,7 @@ soup_dns_lookup_free
 soup_ssl_supported
 <SUBSECTION>
 SoupSSLType
+SoupSSLCredentials
 soup_ssl_get_client_credentials
 soup_ssl_free_client_credentials
 soup_ssl_get_server_credentials
@@ -607,6 +612,8 @@ soup_headers_parse_status_line
 <SUBSECTION>
 soup_str_case_equal
 soup_str_case_hash
+<SUBSECTION>
+soup_xml_real_node
 </SECTION>
 
 <SECTION>
index dac46c7..fef4129 100644 (file)
@@ -308,3 +308,12 @@ Miscellaneous functions
 @Returns: 
 
 
+<!-- ##### FUNCTION soup_xml_real_node ##### -->
+<para>
+
+</para>
+
+@node: 
+@Returns: 
+
+
index e397dff..714c88e 100644 (file)
@@ -31,6 +31,12 @@ SSL/TLS handling
 @SOUP_SSL_TYPE_CLIENT: 
 @SOUP_SSL_TYPE_SERVER: 
 
+<!-- ##### TYPEDEF SoupSSLCredentials ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### FUNCTION soup_ssl_get_client_credentials ##### -->
 <para>
 
@@ -74,7 +80,7 @@ SSL/TLS handling
 @sock: 
 @type: 
 @remote_host: 
-@credentials: 
+@creds: 
 @Returns: 
 
 
index 0f043ef..c4b66f0 100644 (file)
@@ -30,17 +30,17 @@ gboolean soup_ssl_supported = TRUE;
 
 #define DH_BITS 1024
 
-typedef struct {
-       gnutls_certificate_credentials cred;
+struct SoupSSLCredentials {
+       gnutls_certificate_credentials creds;
        gboolean have_ca_file;
-} SoupGNUTLSCred;
+};
 
 typedef struct {
        GIOChannel channel;
        int fd;
        GIOChannel *real_sock;
        gnutls_session session;
-       SoupGNUTLSCred *cred;
+       SoupSSLCredentials *creds;
        char *hostname;
        gboolean established;
        SoupSSLType type;
@@ -156,7 +156,7 @@ again:
                return G_IO_STATUS_ERROR;
        }
 
-       if (chan->type == SOUP_SSL_TYPE_CLIENT && chan->cred->have_ca_file &&
+       if (chan->type == SOUP_SSL_TYPE_CLIENT && chan->creds->have_ca_file &&
            !verify_certificate (chan->session, chan->hostname, err))
                return G_IO_STATUS_ERROR;
 
@@ -368,7 +368,7 @@ THROW_CREATE_ERROR:
  * @sock: a #GIOChannel wrapping a TCP socket.
  * @type: whether this is a client or server socket
  * @remote_host: the hostname of the remote machine
- * @credentials: a client or server credentials structure
+ * @creds: a client or server credentials structure
  *
  * This attempts to wrap a new #GIOChannel around @sock that
  * will SSL-encrypt/decrypt all traffic through it.
@@ -378,17 +378,16 @@ THROW_CREATE_ERROR:
  **/
 GIOChannel *
 soup_ssl_wrap_iochannel (GIOChannel *sock, SoupSSLType type,
-                        const char *remote_host, gpointer credentials)
+                        const char *remote_host, SoupSSLCredentials *creds)
 {
        SoupGNUTLSChannel *chan = NULL;
        GIOChannel *gchan = NULL;
        gnutls_session session = NULL;
-       SoupGNUTLSCred *cred = credentials;
        int sockfd;
        int ret;
 
        g_return_val_if_fail (sock != NULL, NULL);
-       g_return_val_if_fail (credentials != NULL, NULL);
+       g_return_val_if_fail (creds != NULL, NULL);
 
        sockfd = g_io_channel_unix_get_fd (sock);
        if (!sockfd) {
@@ -405,7 +404,7 @@ soup_ssl_wrap_iochannel (GIOChannel *sock, SoupSSLType type,
                goto THROW_CREATE_ERROR;
 
        if (gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE,
-                                   cred->cred) != 0)
+                                   creds->creds) != 0)
                goto THROW_CREATE_ERROR;
 
        if (type == SOUP_SSL_TYPE_SERVER)
@@ -417,7 +416,7 @@ soup_ssl_wrap_iochannel (GIOChannel *sock, SoupSSLType type,
        chan->fd = sockfd;
        chan->real_sock = sock;
        chan->session = session;
-       chan->cred = cred;
+       chan->creds = creds;
        chan->hostname = g_strdup (remote_host);
        chan->type = type;
        g_io_channel_ref (sock);
@@ -467,22 +466,22 @@ soup_gnutls_init (void)
  * Return value: the client credentials, which must be freed with
  * soup_ssl_free_client_credentials().
  **/
-gpointer
+SoupSSLCredentials *
 soup_ssl_get_client_credentials (const char *ca_file)
 {
-       SoupGNUTLSCred *cred;
+       SoupSSLCredentials *creds;
        int status;
 
        if (!soup_gnutls_inited)
                soup_gnutls_init ();
 
-       cred = g_new0 (SoupGNUTLSCred, 1);
-       gnutls_certificate_allocate_credentials (&cred->cred);
+       creds = g_new0 (SoupSSLCredentials, 1);
+       gnutls_certificate_allocate_credentials (&creds->creds);
 
        if (ca_file) {
-               cred->have_ca_file = TRUE;
+               creds->have_ca_file = TRUE;
                status = gnutls_certificate_set_x509_trust_file (
-                       cred->cred, ca_file, GNUTLS_X509_FMT_PEM);
+                       creds->creds, ca_file, GNUTLS_X509_FMT_PEM);
                if (status < 0) {
                        g_warning ("Failed to set SSL trust file (%s).",
                                   ca_file);
@@ -494,7 +493,7 @@ soup_ssl_get_client_credentials (const char *ca_file)
                }
        }
 
-       return cred;
+       return creds;
 }
 
 /**
@@ -502,15 +501,13 @@ soup_ssl_get_client_credentials (const char *ca_file)
  * @creds: a client credentials structure returned by
  * soup_ssl_get_client_credentials().
  *
- * Frees @client_creds.
+ * Frees @creds.
  **/
 void
-soup_ssl_free_client_credentials (gpointer creds)
+soup_ssl_free_client_credentials (SoupSSLCredentials *creds)
 {
-       SoupGNUTLSCred *cred = creds;
-
-       gnutls_certificate_free_credentials (cred->cred);
-       g_free (cred);
+       gnutls_certificate_free_credentials (creds->creds);
+       g_free (creds);
 }
 
 /**
@@ -526,10 +523,10 @@ soup_ssl_free_client_credentials (gpointer creds)
  * Return value: the server credentials, which must be freed with
  * soup_ssl_free_server_credentials().
  **/
-gpointer
+SoupSSLCredentials *
 soup_ssl_get_server_credentials (const char *cert_file, const char *key_file)
 {
-       SoupGNUTLSCred *cred;
+       SoupSSLCredentials *creds;
 
        if (!soup_gnutls_inited)
                soup_gnutls_init ();
@@ -538,20 +535,20 @@ soup_ssl_get_server_credentials (const char *cert_file, const char *key_file)
                        return NULL;
        }
 
-       cred = g_new0 (SoupGNUTLSCred, 1);
-       gnutls_certificate_allocate_credentials (&cred->cred);
+       creds = g_new0 (SoupSSLCredentials, 1);
+       gnutls_certificate_allocate_credentials (&creds->creds);
 
-       if (gnutls_certificate_set_x509_key_file (cred->cred,
+       if (gnutls_certificate_set_x509_key_file (creds->creds,
                                                  cert_file, key_file,
                                                  GNUTLS_X509_FMT_PEM) != 0) {
                g_warning ("Failed to set SSL certificate and key files "
                           "(%s, %s).", cert_file, key_file);
-               soup_ssl_free_server_credentials (cred);
+               soup_ssl_free_server_credentials (creds);
                return NULL;
        }
 
-       gnutls_certificate_set_dh_params (cred->cred, dh_params);
-       return cred;
+       gnutls_certificate_set_dh_params (creds->creds, dh_params);
+       return creds;
 }
 
 /**
@@ -559,15 +556,13 @@ soup_ssl_get_server_credentials (const char *cert_file, const char *key_file)
  * @creds: a server credentials structure returned by
  * soup_ssl_get_server_credentials().
  *
- * Frees @server_creds.
+ * Frees @creds.
  **/
 void
-soup_ssl_free_server_credentials (gpointer creds)
+soup_ssl_free_server_credentials (SoupSSLCredentials *creds)
 {
-       SoupGNUTLSCred *cred = creds;
-
-       gnutls_certificate_free_credentials (cred->cred);
-       g_free (cred);
+       gnutls_certificate_free_credentials (creds->creds);
+       g_free (creds);
 }
 
 #endif /* HAVE_SSL */
index 90357c9..11b40e6 100644 (file)
@@ -33,7 +33,7 @@ typedef struct {
        guint              port;
 
        char              *ssl_cert_file, *ssl_key_file;
-       gpointer           ssl_creds;
+       SoupSSLCredentials *ssl_creds;
 
        GMainLoop         *loop;
 
index 633d443..5c35d40 100644 (file)
@@ -40,7 +40,7 @@ typedef struct {
        gboolean use_ntlm;
 
        char *ssl_ca_file;
-       gpointer ssl_creds;
+       SoupSSLCredentials *ssl_creds;
 
        GSList *filters;
 
index 1442543..e0b2b1c 100644 (file)
@@ -20,16 +20,19 @@ typedef enum {
        SOUP_SSL_TYPE_SERVER
 } SoupSSLType;
 
-gpointer    soup_ssl_get_client_credentials  (const char  *ca_file);
-void        soup_ssl_free_client_credentials (gpointer     creds);
-gpointer    soup_ssl_get_server_credentials  (const char  *cert_file,
-                                             const char  *key_file);
-void        soup_ssl_free_server_credentials (gpointer     creds);
-
-GIOChannel *soup_ssl_wrap_iochannel          (GIOChannel  *sock,
-                                             SoupSSLType  type,
-                                             const char  *remote_host,
-                                             gpointer     credentials);
+typedef struct SoupSSLCredentials SoupSSLCredentials;
+
+SoupSSLCredentials *soup_ssl_get_client_credentials  (const char         *ca_file);
+void                soup_ssl_free_client_credentials (SoupSSLCredentials *creds);
+
+SoupSSLCredentials *soup_ssl_get_server_credentials  (const char         *cert_file,
+                                                     const char         *key_file);
+void                soup_ssl_free_server_credentials (SoupSSLCredentials *creds);
+
+GIOChannel         *soup_ssl_wrap_iochannel          (GIOChannel         *sock,
+                                                     SoupSSLType         type,
+                                                     const char         *remote_host,
+                                                     SoupSSLCredentials *creds);
 
 #define SOUP_SSL_ERROR soup_ssl_error_quark()