/* SSL support via OpenSSL library.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009 Free Software Foundation, Inc.
+ 2009, 2010, 2011 Free Software Foundation, Inc.
Originally contributed by Christian Fraenkel.
This file is part of GNU Wget.
#include <assert.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
#include <string.h>
#include <openssl/ssl.h>
#include "url.h"
#include "ssl.h"
+#ifdef WINDOWS
+# include <w32sock.h>
+#endif
+
/* Application-wide SSL context. This is common to all SSL
connections. */
static SSL_CTX *ssl_ctx;
bool
ssl_init ()
{
- SSL_METHOD *meth;
+ SSL_METHOD const *meth;
if (ssl_ctx)
/* The SSL has already been initialized. */
case secure_protocol_auto:
meth = SSLv23_client_method ();
break;
+#ifndef OPENSSL_NO_SSL2
case secure_protocol_sslv2:
meth = SSLv2_client_method ();
break;
+#endif
case secure_protocol_sslv3:
meth = SSLv3_client_method ();
break;
while (ret == -1
&& SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
&& errno == EINTR);
+
return ret;
}
{
struct openssl_transport_context *ctx = arg;
SSL *conn = ctx->conn;
- if (timeout == 0)
- return 1;
if (SSL_pending (conn))
return 1;
+ if (timeout == 0)
+ return 1;
return select_fd (fd, timeout, wait_for);
}
int ret;
struct openssl_transport_context *ctx = arg;
SSL *conn = ctx->conn;
+ if (! openssl_poll (fd, 0.0, WAIT_FOR_READ, arg))
+ return 0;
do
ret = SSL_peek (conn, buf, bufsize);
while (ret == -1
if (!conn)
goto error;
#ifndef FD_TO_SOCKET
-# define FD_TO_SOCKET(x) (x)
+# define FD_TO_SOCKET(X) (X)
#endif
if (!SSL_set_fd (conn, FD_TO_SOCKET (fd)))
goto error;