Comment out everything unless HAVE_NSS is defined.
2001-03-09 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-ssl.h: Comment out everything unless HAVE_NSS is defined. * camel-tcp-stream-ssl.c (stream_read): Don't use errno, use nspr's error code stuff. (stream_write): Same. svn path=/trunk/; revision=8626
This commit is contained in:

committed by
Jeffrey Stedfast

parent
21a546759f
commit
6da96db8dd
@ -1,3 +1,12 @@
|
|||||||
|
2001-03-09 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
|
* camel-tcp-stream-ssl.h: Comment out everything unless HAVE_NSS
|
||||||
|
is defined.
|
||||||
|
|
||||||
|
* camel-tcp-stream-ssl.c (stream_read): Don't use errno, use
|
||||||
|
nspr's error code stuff.
|
||||||
|
(stream_write): Same.
|
||||||
|
|
||||||
2001-03-09 Jeffrey Stedfast <fejj@ximian.com>
|
2001-03-09 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
* camel-session.c (camel_session_query_authenticator): Created a
|
* camel-session.c (camel_session_query_authenticator): Created a
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_NSS
|
||||||
#include "camel-tcp-stream-ssl.h"
|
#include "camel-tcp-stream-ssl.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -29,6 +31,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <mozilla/nspr.h>
|
||||||
|
#include <nss.h>
|
||||||
|
#include <ssl.h>
|
||||||
|
|
||||||
static CamelTcpStreamClass *parent_class = NULL;
|
static CamelTcpStreamClass *parent_class = NULL;
|
||||||
|
|
||||||
@ -45,7 +50,6 @@ static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
|
|||||||
static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
|
static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
|
|
||||||
static SECStatus ssl_bad_cert (void *data, PRFileDesc *fd);
|
static SECStatus ssl_bad_cert (void *data, PRFileDesc *fd);
|
||||||
static SECStatus ssl_auth_cert (void *data, PRFileDesc *fd, PRBool checksig, PRBool is_server);
|
static SECStatus ssl_auth_cert (void *data, PRFileDesc *fd, PRBool checksig, PRBool is_server);
|
||||||
|
|
||||||
@ -113,7 +117,6 @@ camel_tcp_stream_ssl_get_type (void)
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* camel_tcp_stream_ssl_new:
|
* camel_tcp_stream_ssl_new:
|
||||||
* @session: camel session
|
* @session: camel session
|
||||||
@ -147,7 +150,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
nread = PR_Read (tcp_stream_ssl->sockfd, buffer, n);
|
nread = PR_Read (tcp_stream_ssl->sockfd, buffer, n);
|
||||||
} while (nread == -1 && errno == EINTR);
|
} while (nread == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
|
||||||
|
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
@ -156,15 +159,15 @@ static ssize_t
|
|||||||
stream_write (CamelStream *stream, const char *buffer, size_t n)
|
stream_write (CamelStream *stream, const char *buffer, size_t n)
|
||||||
{
|
{
|
||||||
CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
|
CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
|
||||||
ssize_t v, written = 0;
|
ssize_t w, written = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
v = PR_Write (tcp_stream_ssl->sockfd, buffer, n);
|
w = PR_Write (tcp_stream_ssl->sockfd, buffer, n);
|
||||||
if (v > 0)
|
if (w > 0)
|
||||||
written += v;
|
written += w;
|
||||||
} while (v == -1 && errno == EINTR);
|
} while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
|
||||||
|
|
||||||
if (v == -1)
|
if (w == -1)
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return written;
|
return written;
|
||||||
@ -198,19 +201,24 @@ static SECStatus
|
|||||||
ssl_bad_cert (void *data, PRFileDesc *fd)
|
ssl_bad_cert (void *data, PRFileDesc *fd)
|
||||||
{
|
{
|
||||||
CamelSession *session;
|
CamelSession *session;
|
||||||
|
gpointer accept;
|
||||||
char *string;
|
char *string;
|
||||||
PRInt32 len;
|
PRInt32 len;
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, SECFailure);
|
g_return_val_if_fail (data != NULL, SECFailure);
|
||||||
g_return_val_if_fail (CAMEL_IS_SESSION (data), SECFailure);
|
g_return_val_if_fail (CAMEL_IS_SESSION (data), SECFailure);
|
||||||
|
|
||||||
|
session = CAMEL_SESSION (data);
|
||||||
|
|
||||||
/* FIXME: International issues here?? */
|
/* FIXME: International issues here?? */
|
||||||
len = PR_GetErrorTextLen (PR_GetError ());
|
len = PR_GetErrorTextLen (PR_GetError ());
|
||||||
string = g_malloc0 (len);
|
string = g_malloc0 (len + 1);
|
||||||
PR_GetErrorText (string);
|
PR_GetErrorText (string);
|
||||||
|
|
||||||
session = CAMEL_SESSION (data);
|
accept = camel_session_query_authenticator (session, CAMEL_AUTHENTICATOR_ACCEPT,
|
||||||
if (camel_session_query_cert_authenticator (session, string))
|
string, FALSE, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (GPOINTER_TO_INT (accept))
|
||||||
return SECSuccess;
|
return SECSuccess;
|
||||||
|
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
@ -282,3 +290,5 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_NSS */
|
||||||
|
@ -30,17 +30,19 @@ extern "C" {
|
|||||||
#pragma }
|
#pragma }
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_NSS
|
||||||
#include <camel/camel-tcp-stream.h>
|
#include <camel/camel-tcp-stream.h>
|
||||||
#include <camel/camel-session.h>
|
#include <camel/camel-session.h>
|
||||||
#include <nspr.h>
|
#include <mozilla/nspr.h>
|
||||||
|
|
||||||
#define CAMEL_TCP_STREAM_SSL_TYPE (camel_tcp_stream_ssl_get_type ())
|
#define CAMEL_TCP_STREAM_SSL_TYPE (camel_tcp_stream_ssl_get_type ())
|
||||||
#define CAMEL_TCP_STREAM_SSL(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TCP_STREAM_SSL_TYPE, CamelTcpStreamSSL))
|
#define CAMEL_TCP_STREAM_SSL(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TCP_STREAM_SSL_TYPE, CamelTcpStreamSSL))
|
||||||
#define CAMEL_TCP_STREAM_SSL_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TCP_STREAM_SSL_TYPE, CamelTcpStreamSSLClass))
|
#define CAMEL_TCP_STREAM_SSL_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TCP_STREAM_SSL_TYPE, CamelTcpStreamSSLClass))
|
||||||
#define CAMEL_IS_TCP_STREAM_SSL(o) (CAMEL_CHECK_TYPE((o), CAMEL_TCP_STREAM_SSL_TYPE))
|
#define CAMEL_IS_TCP_STREAM_SSL(o) (CAMEL_CHECK_TYPE((o), CAMEL_TCP_STREAM_SSL_TYPE))
|
||||||
|
|
||||||
struct _CamelTcpStreamSSL
|
struct _CamelTcpStreamSSL {
|
||||||
{
|
|
||||||
CamelTcpStream parent_object;
|
CamelTcpStream parent_object;
|
||||||
|
|
||||||
PRFileDesc *sockfd;
|
PRFileDesc *sockfd;
|
||||||
@ -62,6 +64,8 @@ CamelType camel_tcp_stream_ssl_get_type (void);
|
|||||||
/* public methods */
|
/* public methods */
|
||||||
CamelStream *camel_tcp_stream_ssl_new (CamelSession *session, const char *expected_host);
|
CamelStream *camel_tcp_stream_ssl_new (CamelSession *session, const char *expected_host);
|
||||||
|
|
||||||
|
#endif /* HAVE_NSS */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
Reference in New Issue
Block a user