diff options
author | Dan Winship <danw@src.gnome.org> | 2002-03-11 10:33:27 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2002-03-11 10:33:27 +0800 |
commit | 6024691d3c352e0c845672667cd2ef6a9e3bfdad (patch) | |
tree | 608115b1b394f0f64b7de202b599f6df4ccdb85c /camel | |
parent | b1b809031f5a11223d97ee02d21fb6bb3693a367 (diff) | |
download | gsoc2013-evolution-6024691d3c352e0c845672667cd2ef6a9e3bfdad.tar.gz gsoc2013-evolution-6024691d3c352e0c845672667cd2ef6a9e3bfdad.tar.zst gsoc2013-evolution-6024691d3c352e0c845672667cd2ef6a9e3bfdad.zip |
Rename the OpenSSL implementation of things to match the NSS
implementation so that callers don't need to care which one is
being used.
* camel-tcp-stream-openssl.c: Implement CamelTcpStreamSSL, not
CamelTcpStreamOpenSSL. Rename methods as well. Replace the
camel-tcp-stream-openssl.h include with camel-tcp-stream-ssl.h.
* camel-tcp-stream-openssl.h: Gone.
* camel-tcp-stream-ssl.c: Add a note explaining that this
implementation is only used for NSS, and that OpenSSL's
implementation is in another file. (Should probably do some CVS
renaming magic at some point.)
* camel-http-stream.c (http_connect): Remove OpenSSL refs; the
previously-NSS-specific code works for both now.
* camel-remote-store.c: Likewise.
* providers/smtp/camel-smtp-transport.c: Likewise.
* providers/pop3/camel-pop3-store.c: Likewise.
* Makefile.am (libcamelinclude_HEADERS): Remove
camel-tcp-stream-openssl.h
svn path=/trunk/; revision=16093
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 29 | ||||
-rw-r--r-- | camel/Makefile.am | 1 | ||||
-rw-r--r-- | camel/camel-http-stream.c | 13 | ||||
-rw-r--r-- | camel/camel-remote-store.c | 16 | ||||
-rw-r--r-- | camel/camel-tcp-stream-openssl.c | 94 | ||||
-rw-r--r-- | camel/camel-tcp-stream-openssl.h | 68 | ||||
-rw-r--r-- | camel/camel-tcp-stream-ssl.c | 7 | ||||
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 39 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 37 |
9 files changed, 111 insertions, 193 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 04ac36003d..c842dd59c7 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,34 @@ 2002-03-10 Dan Winship <danw@ximian.com> + Rename the OpenSSL implementation of things to match the NSS + implementation so that callers don't need to care which one is + being used. + + * camel-tcp-stream-openssl.c: Implement CamelTcpStreamSSL, not + CamelTcpStreamOpenSSL. Rename methods as well. Replace the + camel-tcp-stream-openssl.h include with camel-tcp-stream-ssl.h. + + * camel-tcp-stream-openssl.h: Gone. + + * camel-tcp-stream-ssl.c: Add a note explaining that this + implementation is only used for NSS, and that OpenSSL's + implementation is in another file. (Should probably do some CVS + renaming magic at some point.) + + * camel-http-stream.c (http_connect): Remove OpenSSL refs; the + previously-NSS-specific code works for both now. + + * camel-remote-store.c: Likewise. + + * providers/smtp/camel-smtp-transport.c: Likewise. + + * providers/pop3/camel-pop3-store.c: Likewise. + + * Makefile.am (libcamelinclude_HEADERS): Remove + camel-tcp-stream-openssl.h + +2002-03-10 Dan Winship <danw@ximian.com> + * camel-tcp-stream.c (camel_tcp_stream_get_socket): Remove this: it couldn't be generically used, because different subclasses returned entirely different types of data. diff --git a/camel/Makefile.am b/camel/Makefile.am index a59d75f496..075ac1077f 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -183,7 +183,6 @@ libcamelinclude_HEADERS = \ camel-stream.h \ camel-tcp-stream-raw.h \ camel-tcp-stream-ssl.h \ - camel-tcp-stream-openssl.h \ camel-tcp-stream.h \ camel-transport.h \ camel-types.h \ diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c index 9c1a5a10f0..e0cdaba430 100644 --- a/camel/camel-http-stream.c +++ b/camel/camel-http-stream.c @@ -34,12 +34,9 @@ #include "camel-http-stream.h" #include "camel-stream-buffer.h" #include "camel-tcp-stream-raw.h" -#ifdef HAVE_NSS +#ifdef HAVE_SSL #include "camel-tcp-stream-ssl.h" #endif -#ifdef HAVE_OPENSSL -#include "camel-tcp-stream-openssl.h" -#endif #include "camel-exception.h" #include "camel-session.h" @@ -182,13 +179,9 @@ http_connect (CamelService *service, CamelURL *url) int errsave; if (!strcasecmp (url->protocol, "https")) { -#ifdef HAVE_NSS +#ifdef HAVE_SSL stream = camel_tcp_stream_ssl_new (service, url->host); -#else -#ifdef HAVE_OPENSSL - stream = camel_tcp_stream_openssl_new (service, url->host); -#endif /* HAVE_OPENSSL */ -#endif /* HAVE_NSS */ +#endif } else { stream = camel_tcp_stream_raw_new (); } diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c index 8c299cec0c..08308c8253 100644 --- a/camel/camel-remote-store.c +++ b/camel/camel-remote-store.c @@ -47,14 +47,10 @@ #include "camel-tcp-stream.h" #include "camel-tcp-stream-raw.h" -#ifdef HAVE_NSS +#ifdef HAVE_SSL #include "camel-tcp-stream-ssl.h" #endif -#ifdef HAVE_OPENSSL -#include "camel-tcp-stream-openssl.h" -#endif - #include "camel-url.h" #include "string-utils.h" @@ -240,21 +236,15 @@ remote_connect (CamelService *service, CamelException *ex) else port = store->default_port; -#if defined(HAVE_NSS) || defined(HAVE_OPENSSL) +#ifdef HAVE_SSL if (store->use_ssl) { -#ifdef HAVE_NSS - /* this is the preferred SSL implementation */ tcp_stream = camel_tcp_stream_ssl_new (service, service->url->host); -#else - /* use openssl... */ - tcp_stream = camel_tcp_stream_openssl_new (service, service->url->host); -#endif /* HAVE_NSS */ } else { tcp_stream = camel_tcp_stream_raw_new (); } #else tcp_stream = camel_tcp_stream_raw_new (); -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); camel_free_host(h); diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c index 7996b37ae5..785f5ad74b 100644 --- a/camel/camel-tcp-stream-openssl.c +++ b/camel/camel-tcp-stream-openssl.c @@ -26,7 +26,7 @@ #ifdef HAVE_OPENSSL -#include "camel-tcp-stream-openssl.h" +#include "camel-tcp-stream-ssl.h" #include <openssl/ssl.h> #include <openssl/x509.h> @@ -51,8 +51,8 @@ static CamelTcpStreamClass *parent_class = NULL; -/* Returns the class for a CamelTcpStreamOpenSSL */ -#define CTSR_CLASS(so) CAMEL_TCP_STREAM_OPENSSL_CLASS (CAMEL_OBJECT_GET_CLASS (so)) +/* Returns the class for a CamelTcpStreamSSL */ +#define CTSR_CLASS(so) CAMEL_TCP_STREAM_SSL_CLASS (CAMEL_OBJECT_GET_CLASS (so)) static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n); static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n); @@ -65,9 +65,9 @@ static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *da static CamelTcpAddress *stream_get_local_address (CamelTcpStream *stream); static CamelTcpAddress *stream_get_remote_address (CamelTcpStream *stream); -static SSL *open_ssl_connection (CamelService *service, int sockfd, CamelTcpStreamOpenSSL *openssl); +static SSL *open_ssl_connection (CamelService *service, int sockfd, CamelTcpStreamSSL *openssl); -struct _CamelTcpStreamOpenSSLPrivate { +struct _CamelTcpStreamSSLPrivate { int sockfd; SSL *ssl; @@ -77,12 +77,12 @@ struct _CamelTcpStreamOpenSSLPrivate { }; static void -camel_tcp_stream_openssl_class_init (CamelTcpStreamOpenSSLClass *camel_tcp_stream_openssl_class) +camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_class) { CamelTcpStreamClass *camel_tcp_stream_class = - CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_openssl_class); + CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_ssl_class); CamelStreamClass *camel_stream_class = - CAMEL_STREAM_CLASS (camel_tcp_stream_openssl_class); + CAMEL_STREAM_CLASS (camel_tcp_stream_ssl_class); parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ())); @@ -104,18 +104,18 @@ camel_tcp_stream_openssl_class_init (CamelTcpStreamOpenSSLClass *camel_tcp_strea } static void -camel_tcp_stream_openssl_init (gpointer object, gpointer klass) +camel_tcp_stream_ssl_init (gpointer object, gpointer klass) { - CamelTcpStreamOpenSSL *stream = CAMEL_TCP_STREAM_OPENSSL (object); + CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object); - stream->priv = g_new0 (struct _CamelTcpStreamOpenSSLPrivate, 1); + stream->priv = g_new0 (struct _CamelTcpStreamSSLPrivate, 1); stream->priv->sockfd = -1; } static void -camel_tcp_stream_openssl_finalize (CamelObject *object) +camel_tcp_stream_ssl_finalize (CamelObject *object) { - CamelTcpStreamOpenSSL *stream = CAMEL_TCP_STREAM_OPENSSL (object); + CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object); if (stream->priv->ssl) { SSL_shutdown (stream->priv->ssl); @@ -137,19 +137,19 @@ camel_tcp_stream_openssl_finalize (CamelObject *object) CamelType -camel_tcp_stream_openssl_get_type (void) +camel_tcp_stream_ssl_get_type (void) { static CamelType type = CAMEL_INVALID_TYPE; if (type == CAMEL_INVALID_TYPE) { type = camel_type_register (camel_tcp_stream_get_type (), - "CamelTcpStreamOpenSSL", - sizeof (CamelTcpStreamOpenSSL), - sizeof (CamelTcpStreamOpenSSLClass), - (CamelObjectClassInitFunc) camel_tcp_stream_openssl_class_init, + "CamelTcpStreamSSL", + sizeof (CamelTcpStreamSSL), + sizeof (CamelTcpStreamSSLClass), + (CamelObjectClassInitFunc) camel_tcp_stream_ssl_class_init, NULL, - (CamelObjectInitFunc) camel_tcp_stream_openssl_init, - (CamelObjectFinalizeFunc) camel_tcp_stream_openssl_finalize); + (CamelObjectInitFunc) camel_tcp_stream_ssl_init, + (CamelObjectFinalizeFunc) camel_tcp_stream_ssl_finalize); } return type; @@ -157,7 +157,7 @@ camel_tcp_stream_openssl_get_type (void) /** - * camel_tcp_stream_openssl_new: + * camel_tcp_stream_ssl_new: * @service: camel service * @expected_host: host that the stream is expecting to connect with. * @@ -168,11 +168,11 @@ camel_tcp_stream_openssl_get_type (void) * Return value: a ssl stream (in ssl mode) **/ CamelStream * -camel_tcp_stream_openssl_new (CamelService *service, const char *expected_host) +camel_tcp_stream_ssl_new (CamelService *service, const char *expected_host) { - CamelTcpStreamOpenSSL *stream; + CamelTcpStreamSSL *stream; - stream = CAMEL_TCP_STREAM_OPENSSL (camel_object_new (camel_tcp_stream_openssl_get_type ())); + stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ())); stream->priv->service = service; stream->priv->expected_host = g_strdup (expected_host); @@ -183,7 +183,7 @@ camel_tcp_stream_openssl_new (CamelService *service, const char *expected_host) /** - * camel_tcp_stream_openssl_new_raw: + * camel_tcp_stream_ssl_new_raw: * @service: camel service * @expected_host: host that the stream is expecting to connect with. * @@ -194,11 +194,11 @@ camel_tcp_stream_openssl_new (CamelService *service, const char *expected_host) * Return value: a ssl-capable stream (in non ssl mode) **/ CamelStream * -camel_tcp_stream_openssl_new_raw (CamelService *service, const char *expected_host) +camel_tcp_stream_ssl_new_raw (CamelService *service, const char *expected_host) { - CamelTcpStreamOpenSSL *stream; + CamelTcpStreamSSL *stream; - stream = CAMEL_TCP_STREAM_OPENSSL (camel_object_new (camel_tcp_stream_openssl_get_type ())); + stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ())); stream->priv->service = service; stream->priv->expected_host = g_strdup (expected_host); @@ -236,7 +236,7 @@ ssl_errno (SSL *ssl, int ret) /** - * camel_tcp_stream_openssl_enable_ssl: + * camel_tcp_stream_ssl_enable_ssl: * @stream: ssl stream * * Toggles an ssl-capable stream into ssl mode (if it isn't already). @@ -244,11 +244,11 @@ ssl_errno (SSL *ssl, int ret) * Returns 0 on success or -1 on fail. **/ int -camel_tcp_stream_openssl_enable_ssl (CamelTcpStreamOpenSSL *stream) +camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *stream) { SSL *ssl; - g_return_val_if_fail (CAMEL_IS_TCP_STREAM_OPENSSL (stream), -1); + g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (stream), -1); if (stream->priv->sockfd != -1 && !stream->priv->ssl_mode) { ssl = open_ssl_connection (stream->priv->service, stream->priv->sockfd, stream); @@ -269,7 +269,7 @@ camel_tcp_stream_openssl_enable_ssl (CamelTcpStreamOpenSSL *stream) static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n) { - CamelTcpStreamOpenSSL *openssl = CAMEL_TCP_STREAM_OPENSSL (stream); + CamelTcpStreamSSL *openssl = CAMEL_TCP_STREAM_SSL (stream); SSL *ssl = openssl->priv->ssl; ssize_t nread; int cancel_fd; @@ -336,7 +336,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n) { - CamelTcpStreamOpenSSL *openssl = CAMEL_TCP_STREAM_OPENSSL (stream); + CamelTcpStreamSSL *openssl = CAMEL_TCP_STREAM_SSL (stream); SSL *ssl = openssl->priv->ssl; ssize_t w, written = 0; int cancel_fd; @@ -438,13 +438,13 @@ close_ssl_connection (SSL *ssl) static int stream_close (CamelStream *stream) { - close_ssl_connection (((CamelTcpStreamOpenSSL *)stream)->priv->ssl); - ((CamelTcpStreamOpenSSL *)stream)->priv->ssl = NULL; + close_ssl_connection (((CamelTcpStreamSSL *)stream)->priv->ssl); + ((CamelTcpStreamSSL *)stream)->priv->ssl = NULL; - if (close (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd) == -1) + if (close (((CamelTcpStreamSSL *)stream)->priv->sockfd) == -1) return -1; - ((CamelTcpStreamOpenSSL *)stream)->priv->sockfd = -1; + ((CamelTcpStreamSSL *)stream)->priv->sockfd = -1; return 0; } @@ -589,7 +589,7 @@ ssl_cert_is_saved (const char *certid) static int ssl_verify (int ok, X509_STORE_CTX *ctx) { - CamelTcpStreamOpenSSL *stream; + CamelTcpStreamSSL *stream; X509 *cert; SSL *ssl; int err; @@ -631,7 +631,7 @@ ssl_verify (int ok, X509_STORE_CTX *ctx) } static SSL * -open_ssl_connection (CamelService *service, int sockfd, CamelTcpStreamOpenSSL *openssl) +open_ssl_connection (CamelService *service, int sockfd, CamelTcpStreamSSL *openssl) { SSL_CTX *ssl_ctx = NULL; SSL *ssl = NULL; @@ -670,7 +670,7 @@ open_ssl_connection (CamelService *service, int sockfd, CamelTcpStreamOpenSSL *o static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port) { - CamelTcpStreamOpenSSL *openssl = CAMEL_TCP_STREAM_OPENSSL (stream); + CamelTcpStreamSSL *openssl = CAMEL_TCP_STREAM_SSL (stream); SSL *ssl = NULL; int fd; @@ -743,7 +743,7 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data) if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { int flags; - flags = fcntl (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd, F_GETFL); + flags = fcntl (((CamelTcpStreamSSL *)stream)->priv->sockfd, F_GETFL); if (flags == -1) return -1; @@ -752,7 +752,7 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data) return 0; } - return getsockopt (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd, + return getsockopt (((CamelTcpStreamSSL *)stream)->priv->sockfd, get_sockopt_level (data), optname, (void *) &data->value, @@ -770,20 +770,20 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data) if (data->option == CAMEL_SOCKOPT_NONBLOCKING) { int flags, set; - flags = fcntl (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd, F_GETFL); + flags = fcntl (((CamelTcpStreamSSL *)stream)->priv->sockfd, F_GETFL); if (flags == -1) return -1; set = data->value.non_blocking ? 1 : 0; flags = (flags & ~O_NONBLOCK) | (set & O_NONBLOCK); - if (fcntl (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd, F_SETFL, flags) == -1) + if (fcntl (((CamelTcpStreamSSL *)stream)->priv->sockfd, F_SETFL, flags) == -1) return -1; return 0; } - return setsockopt (((CamelTcpStreamOpenSSL *)stream)->priv->sockfd, + return setsockopt (((CamelTcpStreamSSL *)stream)->priv->sockfd, get_sockopt_level (data), optname, (void *) &data->value, @@ -796,7 +796,7 @@ stream_get_local_address (CamelTcpStream *stream) struct sockaddr_in sin; socklen_t len; - if (getsockname (CAMEL_TCP_STREAM_OPENSSL (stream)->priv->sockfd, + if (getsockname (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, (struct sockaddr *)&sin, &len) == -1) return NULL; @@ -810,7 +810,7 @@ stream_get_remote_address (CamelTcpStream *stream) struct sockaddr_in sin; socklen_t len; - if (getpeername (CAMEL_TCP_STREAM_OPENSSL (stream)->priv->sockfd, + if (getpeername (CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd, (struct sockaddr *)&sin, &len) == -1) return NULL; diff --git a/camel/camel-tcp-stream-openssl.h b/camel/camel-tcp-stream-openssl.h deleted file mode 100644 index 9509eaf343..0000000000 --- a/camel/camel-tcp-stream-openssl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2001 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - - -#ifndef CAMEL_TCP_STREAM_OPENSSL_H -#define CAMEL_TCP_STREAM_OPENSSL_H - - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include <camel/camel-tcp-stream.h> - -#define CAMEL_TCP_STREAM_OPENSSL_TYPE (camel_tcp_stream_openssl_get_type ()) -#define CAMEL_TCP_STREAM_OPENSSL(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TCP_STREAM_OPENSSL_TYPE, CamelTcpStreamOpenSSL)) -#define CAMEL_TCP_STREAM_OPENSSL_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TCP_STREAM_OPENSSL_TYPE, CamelTcpStreamOpenSSLClass)) -#define CAMEL_IS_TCP_STREAM_OPENSSL(o) (CAMEL_CHECK_TYPE((o), CAMEL_TCP_STREAM_OPENSSL_TYPE)) - -struct _CamelTcpStreamOpenSSL -{ - CamelTcpStream parent_object; - - struct _CamelTcpStreamOpenSSLPrivate *priv; -}; - -typedef struct { - CamelTcpStreamClass parent_class; - - /* virtual functions */ - -} CamelTcpStreamOpenSSLClass; - -/* Standard Camel function */ -CamelType camel_tcp_stream_openssl_get_type (void); - -/* public methods */ -CamelStream *camel_tcp_stream_openssl_new (CamelService *service, const char *expected_host); - -CamelStream *camel_tcp_stream_openssl_new_raw (CamelService *service, const char *expected_host); - -int camel_tcp_stream_openssl_enable_ssl (CamelTcpStreamOpenSSL *ssl); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* CAMEL_TCP_STREAM_OPENSSL_H */ diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c index ac78cc92cb..f44f87dc36 100644 --- a/camel/camel-tcp-stream-ssl.c +++ b/camel/camel-tcp-stream-ssl.c @@ -20,6 +20,13 @@ * */ +/* NOTE: This is the default implementation of CamelTcpStreamSSL, + * used when the Mozilla NSS libraries are used. If you configured + * OpenSSL support instead, then this file won't be compiled and + * the CamelTcpStreamSSL implementation in camel-tcp-stream-openssl.c + * will be used instead. + */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 515e982b95..5a9a8aa7f0 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -51,12 +51,8 @@ #include "camel-data-cache.h" #include "camel-tcp-stream.h" #include "camel-tcp-stream-raw.h" -#ifdef HAVE_NSS +#ifdef HAVE_SSL #include "camel-tcp-stream-ssl.h" -#include <prnetdb.h> -#endif -#ifdef HAVE_OPENSSL -#include "camel-tcp-stream-openssl.h" #endif /* Specified in RFC 1939 */ @@ -161,30 +157,21 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, int *s port = service->url->port ? service->url->port : 110; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL /* FIXME: check for "always" and "when-possible" to support STARTTLS */ if (camel_url_get_param (service->url, "use_ssl")) { - if (!try_starttls) - port = service->url->port ? service->url->port : 995; -#ifdef HAVE_NSS - /* this is the preferred SSL implementation */ if (try_starttls) tcp_stream = camel_tcp_stream_ssl_new_raw (service, service->url->host); - else + else { + port = service->url->port ? service->url->port : 995; tcp_stream = camel_tcp_stream_ssl_new (service, service->url->host); -#else - /* use openssl... */ - if (try_starttls) - tcp_stream = camel_tcp_stream_openssl_new_raw (service, service->url->host); - else - tcp_stream = camel_tcp_stream_openssl_new (service, service->url->host); -#endif /* HAVE_NSS */ + } } else { tcp_stream = camel_tcp_stream_raw_new (); } #else tcp_stream = camel_tcp_stream_raw_new (); -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); camel_free_host (h); @@ -211,7 +198,7 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, int *s if (stls_support) *stls_support = store->engine->capa & CAMEL_POP3_CAP_STLS; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL if (store->engine) { if (ssl_mode == USE_SSL_WHEN_POSSIBLE) { if (store->engine->capa & CAMEL_POP3_CAP_STLS) @@ -233,13 +220,13 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, int *s } } } -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ camel_object_unref (CAMEL_OBJECT (tcp_stream)); return store->engine != NULL; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL starttls: /* as soon as we send a STLS command, all hope is lost of a clean QUIT if problems arise */ clean_quit = FALSE; @@ -259,11 +246,7 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, int *s } /* Okay, now toggle SSL/TLS mode */ -#ifdef HAVE_NSS ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)); -#else /* HAVE_OPENSSL */ - ret = camel_tcp_stream_openssl_enable_ssl (CAMEL_TCP_STREAM_OPENSSL (tcp_stream)); -#endif camel_object_unref (CAMEL_OBJECT (tcp_stream)); @@ -294,7 +277,7 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls, int *s store->engine = NULL; return FALSE; -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ } static struct { @@ -314,7 +297,7 @@ static struct { static gboolean connect_to_server_wrapper (CamelService *service, CamelException *ex) { -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL const char *use_ssl; int stls_supported; int i, ssl_mode; diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 26cf4aa17f..d45c617c02 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -49,12 +49,9 @@ #include "camel-stream-buffer.h" #include "camel-tcp-stream.h" #include "camel-tcp-stream-raw.h" -#ifdef HAVE_NSS +#ifdef HAVE_SSL #include "camel-tcp-stream-ssl.h" #endif -#ifdef HAVE_OPENSSL -#include "camel-tcp-stream-openssl.h" -#endif #include "camel-session.h" #include "camel-exception.h" #include "camel-sasl.h" @@ -261,28 +258,20 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) port = service->url->port ? service->url->port : SMTP_PORT; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL if (transport->flags & CAMEL_SMTP_TRANSPORT_USE_SSL) { - if (!try_starttls) - port = service->url->port ? service->url->port : 465; -#ifdef HAVE_NSS - /* use the preferred implementation - NSS */ if (try_starttls) tcp_stream = camel_tcp_stream_ssl_new_raw (service, service->url->host); - else + else { + port = service->url->port ? service->url->port : 465; tcp_stream = camel_tcp_stream_ssl_new (service, service->url->host); -#else - if (try_starttls) - tcp_stream = camel_tcp_stream_openssl_new_raw (service, service->url->host); - else - tcp_stream = camel_tcp_stream_openssl_new (service, service->url->host); -#endif /* HAVE_NSS */ + } } else { tcp_stream = camel_tcp_stream_raw_new (); } #else tcp_stream = camel_tcp_stream_raw_new (); -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ ret = camel_tcp_stream_connect (CAMEL_TCP_STREAM (tcp_stream), h, port); camel_free_host (h); @@ -335,7 +324,7 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) smtp_helo (transport, ex); } -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL if (transport->flags & CAMEL_SMTP_TRANSPORT_USE_SSL_WHEN_POSSIBLE) { /* try_starttls is always TRUE here */ if (transport->flags & CAMEL_SMTP_TRANSPORT_STARTTLS) @@ -353,11 +342,11 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) } } } -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ return TRUE; -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL starttls: d(fprintf (stderr, "sending : STARTTLS\r\n")); if (camel_stream_write (tcp_stream, "STARTTLS\r\n", 10) == -1) { @@ -384,11 +373,7 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) } while (*(respbuf+3) == '-'); /* if we got "220-" then loop again */ /* Okay, now toggle SSL/TLS mode */ -#ifdef HAVE_NSS ret = camel_tcp_stream_ssl_enable_ssl (CAMEL_TCP_STREAM_SSL (tcp_stream)); -#else /* HAVE_OPENSSL */ - ret = camel_tcp_stream_openssl_enable_ssl (CAMEL_TCP_STREAM_OPENSSL (tcp_stream)); -#endif if (ret != -1) return TRUE; @@ -403,7 +388,7 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) transport->ostream = NULL; return FALSE; -#endif /* HAVE_NSS || HAVE_OPENSSL */ +#endif /* HAVE_SSL */ } #define EXCEPTION_RETRY(ex) (camel_exception_get_id (ex) != CAMEL_EXCEPTION_USER_CANCEL && \ @@ -412,7 +397,7 @@ connect_to_server (CamelService *service, int try_starttls, CamelException *ex) static gboolean connect_to_server_wrapper (CamelService *service, CamelException *ex) { -#if defined (HAVE_NSS) || defined (HAVE_OPENSSL) +#ifdef HAVE_SSL CamelSmtpTransport *transport = (CamelSmtpTransport *) service; if (transport->flags & CAMEL_SMTP_TRANSPORT_USE_SSL_ALWAYS) { |