]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Drop OpenSSL support.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 8 Nov 2013 15:35:27 +0000 (15:35 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 8 Nov 2013 15:35:27 +0000 (15:35 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11419 a1ca3aef-8c08-0410-bb20-df032aa958be

15 files changed:
CHANGES.txt
LICENSE.txt
Makedefs.in
config-scripts/cups-ssl.m4
config.h.in
cups/http-private.h
cups/http.c
cups/tls-openssl.c [deleted file]
doc/help/license.html
scheduler/client.c
scheduler/conf.c
scheduler/conf.h
vcnet/config.h
xcode/CUPS.xcodeproj/project.pbxproj
xcode/config.h

index bbe4479c5d6487cb5acc807f2a43b28ce4ec4771..e82cb1971b7f532fca93ac6cc0c7047469e883a1 100644 (file)
@@ -1,8 +1,9 @@
-CHANGES.txt - 2.0b1 - 2013-11-06
+CHANGES.txt - 2.0b1 - 2013-11-08
 --------------------------------
 
 CHANGES IN CUPS V2.0b1
 
+       - Dropped OpenSSL support in favor of GNU TLS.
        - Dropped "dark wake" support on OS X, which was preventing portables
          from going to sleep when there was a stuck job. We now use a variation
          of the CUPS 1.4 sleep support to do a cleaner sleep
index 75c4a376f195b555fc4d998bc4c1001b2525902a..658ea1e461fc0b0ce7d9d9f63261965a77d65cc3 100644 (file)
@@ -1,6 +1,6 @@
                           CUPS License Agreement
 
-                     Copyright 2007-2012 by Apple Inc.
+                     Copyright 2007-2013 by Apple Inc.
                             1 Infinite Loop
                          Cupertino, CA 95014 USA
 
@@ -10,9 +10,9 @@
 INTRODUCTION
 
 CUPS(tm) is provided under the GNU General Public License ("GPL")
-and GNU Library General Public License ("LGPL"), Version 2, with
-exceptions for Apple operating systems and the OpenSSL toolkit. A
-copy of the exceptions and licenses follow this introduction.
+and GNU Library General Public License ("LGPL"), Version 2, with an
+exception for Apple operating systems. A copy of the exception and
+licenses follow this introduction.
 
 The GNU LGPL applies to the CUPS and CUPS Imaging libraries
 located in the "cups" and "filter" subdirectories of the CUPS
@@ -45,7 +45,7 @@ application, driver, or filter.
 LICENSE EXCEPTIONS
 
 In addition, as the copyright holder of CUPS, Apple Inc. grants
-the following special exceptions:
+the following special exception:
 
      1. Apple Operating System Development License Exception;
 
@@ -86,14 +86,8 @@ the following special exceptions:
             This file is subject to the Apple OS-Developed
             Software exception.
 
-     2. OpenSSL Toolkit License Exception;
-
-       a. Apple Inc. explicitly allows the compilation and
-          distribution of the CUPS software with the OpenSSL
-          Toolkit.
-
-No developer is required to provide these exceptions in a
-derived work.
+No developer is required to provide this exception in a derived
+work.
 
 
 KERBEROS SUPPORT CODE
index 817f18ab1285ad97db3870d6f9fb3b534b5dde82..f55057ae67cb81d0684212798df50ef982b0529a 100644 (file)
@@ -1,16 +1,16 @@
 #
 # "$Id$"
 #
-#   Common makefile definitions for CUPS.
+# Common makefile definitions for CUPS.
 #
-#   Copyright 2007-2013 by Apple Inc.
-#   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+# Copyright 2007-2013 by Apple Inc.
+# Copyright 1997-2007 by Easy Software Products, all rights reserved.
 #
-#   These coded instructions, statements, and computer programs are the
-#   property of Apple Inc. and are protected by Federal copyright
-#   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
-#   which should have been included with this file.  If this file is
-#   file is missing or damaged, see the license at "http://www.cups.org/".
+# These coded instructions, statements, and computer programs are the
+# property of Apple Inc. and are protected by Federal copyright
+# law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+# which should have been included with this file.  If this file is
+# file is missing or damaged, see the license at "http://www.cups.org/".
 #
 
 #
@@ -144,7 +144,7 @@ LAUNCHDLIBS =       @LAUNCHDLIBS@
 LDFLAGS                =       -L../cgi-bin -L../cups -L../filter -L../ppdc \
                        -L../scheduler @LDARCHFLAGS@ \
                        @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
-LINKCUPS       =       @LINKCUPS@ $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(LIBZ)
+LINKCUPS       =       @LINKCUPS@ $(LIBGSSAPI) $(DNSSDLIBS) $(LIBZ)
 LINKCUPSIMAGE  =       @LINKCUPSIMAGE@
 LIBS           =       $(LINKCUPS) $(COMMONLIBS)
 OPTIM          =       @OPTIM@
index faa9cc68e997b06e299d168c0c3c729be55a4a02..9dcb6999dd5f8f060cf23ebac1a463a179fb127c 100644 (file)
@@ -1,28 +1,21 @@
 dnl
 dnl "$Id$"
 dnl
-dnl   OpenSSL/GNUTLS stuff for CUPS.
+dnl TLS stuff for CUPS.
 dnl
-dnl   Copyright 2007-2012 by Apple Inc.
-dnl   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+dnl Copyright 2007-2013 by Apple Inc.
+dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
 dnl
-dnl   These coded instructions, statements, and computer programs are the
-dnl   property of Apple Inc. and are protected by Federal copyright
-dnl   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
-dnl   which should have been included with this file.  If this file is
-dnl   file is missing or damaged, see the license at "http://www.cups.org/".
+dnl These coded instructions, statements, and computer programs are the
+dnl property of Apple Inc. and are protected by Federal copyright
+dnl law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+dnl which should have been included with this file.  If this file is
+dnl file is missing or damaged, see the license at "http://www.cups.org/".
 dnl
 
 AC_ARG_ENABLE(ssl, [  --disable-ssl           disable SSL/TLS support])
 AC_ARG_ENABLE(cdsassl, [  --enable-cdsassl        use CDSA for SSL/TLS support, default=first])
 AC_ARG_ENABLE(gnutls, [  --enable-gnutls         use GNU TLS for SSL/TLS support, default=second])
-AC_ARG_ENABLE(openssl, [  --enable-openssl        use OpenSSL for SSL/TLS support, default=third])
-AC_ARG_WITH(openssl-libs, [  --with-openssl-libs     set directory for OpenSSL library],
-    LDFLAGS="-L$withval $LDFLAGS"
-    DSOFLAGS="-L$withval $DSOFLAGS",)
-AC_ARG_WITH(openssl-includes, [  --with-openssl-includes set directory for OpenSSL includes],
-    CFLAGS="-I$withval $CFLAGS"
-    CPPFLAGS="-I$withval $CPPFLAGS",)
 
 SSLFLAGS=""
 SSLLIBS=""
@@ -94,48 +87,6 @@ if test x$enable_ssl != xno; then
            fi
        fi
     fi
-
-    dnl Check for the OpenSSL library last...
-    if test $have_ssl = 0 -a "x$enable_openssl" != "xno"; then
-       AC_CHECK_HEADER(openssl/ssl.h,[
-           dnl Save the current libraries so the crypto stuff isn't always
-           dnl included...
-           SAVELIBS="$LIBS"
-
-           dnl Some ELF systems can't resolve all the symbols in libcrypto
-           dnl if libcrypto was linked against RSAREF, and fail to link the
-           dnl test program correctly, even though a correct installation
-           dnl of OpenSSL exists.  So we test the linking three times in
-           dnl case the RSAREF libraries are needed.
-
-           for libcrypto in \
-               "-lcrypto" \
-               "-lcrypto -lrsaref" \
-               "-lcrypto -lRSAglue -lrsaref"
-           do
-               AC_CHECK_LIB(ssl,SSL_new,
-                   [have_ssl=1
-                    SSLFLAGS="-DOPENSSL_DISABLE_OLD_DES_SUPPORT"
-                    SSLLIBS="-lssl $libcrypto"
-                    AC_DEFINE(HAVE_SSL)
-                    AC_DEFINE(HAVE_LIBSSL)],,
-                   $libcrypto)
-
-               if test "x${SSLLIBS}" != "x"; then
-                   break
-               fi
-           done
-
-           if test "x${SSLLIBS}" != "x"; then
-               CUPS_SERVERCERT="ssl/server.crt"
-               CUPS_SERVERKEY="ssl/server.key"
-
-               LIBS="$SAVELIBS $SSLLIBS"
-               AC_CHECK_FUNCS(SSL_set_tlsext_host_name)
-           fi
-
-           LIBS="$SAVELIBS"])
-    fi
 fi
 
 IPPALIASES="http"
@@ -143,7 +94,7 @@ if test $have_ssl = 1; then
     AC_MSG_RESULT([    Using SSLLIBS="$SSLLIBS"])
     AC_MSG_RESULT([    Using SSLFLAGS="$SSLFLAGS"])
     IPPALIASES="http https ipps"
-elif test x$enable_cdsa = xyes -o x$enable_gnutls = xyes -o x$enable_openssl = xyes; then
+elif test x$enable_cdsa = xyes -o x$enable_gnutls = xyes; then
     AC_MSG_ERROR([Unable to enable SSL support.])
 fi
 
index f08ea4a5b6d8dc302093c83daa2215e60d136abc..ec4a7785e11f5087b9257383ea5ff53ab01af7dd 100644 (file)
 
 #undef HAVE_CDSASSL
 #undef HAVE_GNUTLS
-#undef HAVE_LIBSSL
 #undef HAVE_SSL
 
 
-/*
- * Do we have the SSL_set_tlsext_host_name function?
- */
-
-#undef HAVE_SSL_SET_TLSEXT_HOST_NAME
-
-
 /*
  * What Security framework headers do we have?
  */
index c0b6d340b9a642bd7b718ac47ba4dbeb6516b709..5fdacd19cd7ecc49b472739d2554ab7b3ec26512 100644 (file)
@@ -73,11 +73,7 @@ typedef int socklen_t;
 #  include "md5-private.h"
 #  include "ipp-private.h"
 
-#  if defined HAVE_LIBSSL
-#    include <openssl/err.h>
-#    include <openssl/rand.h>
-#    include <openssl/ssl.h>
-#  elif defined HAVE_GNUTLS
+#  ifdef HAVE_GNUTLS
 #    include <gnutls/gnutls.h>
 #    include <gnutls/x509.h>
 #    include <gcrypt.h>
@@ -109,7 +105,7 @@ typedef int socklen_t;
 #    endif /* HAVE_SECPOLICYPRIV_H */
 #  elif defined(HAVE_SSPISSL)
 #    include "sspi-private.h"
-#  endif /* HAVE_LIBSSL */
+#  endif /* HAVE_GNUTLS */
 
 #  ifndef WIN32
 #    include <net/if.h>
@@ -152,19 +148,7 @@ extern "C" {
  * Types and functions for SSL support...
  */
 
-#  if defined HAVE_LIBSSL
-/*
- * The OpenSSL library provides its own SSL/TLS context structure for its
- * IO and protocol management.  However, we need to provide our own BIO
- * (basic IO) implementation to do timeouts...
- */
-
-typedef SSL  *http_tls_t;
-typedef void *http_tls_credentials_t;
-
-//extern BIO_METHOD *_httpBIOMethods(void);
-
-#  elif defined HAVE_GNUTLS
+#  ifdef HAVE_GNUTLS
 /*
  * The GNU TLS library is more of a "bare metal" SSL/TLS library...
  */
@@ -215,7 +199,7 @@ typedef void *http_tls_credentials_t;
 
 typedef void *http_tls_t;
 typedef void *http_tls_credentials_t;
-#  endif /* HAVE_LIBSSL */
+#  endif /* HAVE_GNUTLS */
 
 typedef enum _http_coding_e            /**** HTTP content coding enumeration ****/
 {
index 5beb9a94f73e7cab08ad287287bb8aa78d005f49..51b63197cc516475716d3105933d3a5f53a24abe 100644 (file)
@@ -75,15 +75,13 @@ static int          http_tls_start(http_t *http);
 static void            http_tls_stop(http_t *http);
 static int             http_tls_upgrade(http_t *http);
 static int             http_tls_write(http_t *http, const char *buf, int len);
-#  ifdef HAVE_LIBSSL
-#    include "tls-openssl.c"
-#  elif defined(HAVE_GNUTLS)
+#  ifdef HAVE_GNUTLS
 #    include "tls-gnutls.c"
 #  elif defined(HAVE_CDSASSL)
 #    include "tls-darwin.c"
 #  else
 #    include "tls-sspi.c"
-#  endif /* HAVE_LIBSSL */
+#  endif /* HAVE_GNUTLS */
 #endif /* HAVE_SSL */
 
 
@@ -1120,20 +1118,7 @@ httpGetReady(http_t *http)               /* I - HTTP connection */
     return (http->used);
 #ifdef HAVE_SSL
   else if (http->tls)
-  {
-    size_t     ready;                  /* Ready bytes */
-
-#  ifdef HAVE_LIBSSL
-    if ((ready = SSL_pending((SSL *)(http->tls))) > 0)
-      return (ready);
-#  elif defined(HAVE_GNUTLS)
-    if ((ready = gnutls_record_check_pending(http->tls)) > 0)
-      return (ready);
-#  elif defined(HAVE_CDSASSL)
-    if (!SSLGetBufferedReadSize(http->tls, &ready) && ready > 0)
-      return (ready);
-#  endif /* HAVE_LIBSSL */
-  }
+    return (http_tls_pending(http));
 #endif /* HAVE_SSL */
 
   return (0);
@@ -1539,10 +1524,6 @@ httpInitialize(void)
 #ifdef WIN32
   WSADATA      winsockdata;            /* WinSock data */
 #endif /* WIN32 */
-#ifdef HAVE_LIBSSL
-  int          i;                      /* Looping var */
-  unsigned char        data[1024];             /* Seed data */
-#endif /* HAVE_LIBSSL */
 
 
   _cupsGlobalLock();
diff --git a/cups/tls-openssl.c b/cups/tls-openssl.c
deleted file mode 100644 (file)
index 78ec40f..0000000
+++ /dev/null
@@ -1,1239 +0,0 @@
-/*
- * "$Id$"
- *
- * TLS support code for CUPS using OpenSSL.
- *
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
- */
-
-
-/*
- * Local functions...
- */
-
-static int             make_certificate(cupsd_client_t *con);
-#if defined(HAVE_SSL) && defined(HAVE_LIBSSL)
-/*
- * BIO methods for OpenSSL...
- */
-
-static int             http_bio_write(BIO *h, const char *buf, int num);
-static int             http_bio_read(BIO *h, char *buf, int size);
-static int             http_bio_puts(BIO *h, const char *str);
-static long            http_bio_ctrl(BIO *h, int cmd, long arg1, void *arg2);
-static int             http_bio_new(BIO *h);
-static int             http_bio_free(BIO *data);
-
-static BIO_METHOD      http_bio_methods =
-                       {
-                         BIO_TYPE_SOCKET,
-                         "http",
-                         http_bio_write,
-                         http_bio_read,
-                         http_bio_puts,
-                         NULL, /* http_bio_gets, */
-                         http_bio_ctrl,
-                         http_bio_new,
-                         http_bio_free,
-                         NULL,
-                       };
-#endif /* HAVE_SSL && HAVE_LIBSSL */
-
-
-
-
-/*
- * 'http_tls_initialize()' - Initialize the TLS stack.
- */
-
-static void
-http_tls_initialize(void)
-{
-#ifdef HAVE_GNUTLS
- /*
-  * Initialize GNU TLS...
-  */
-
-  gnutls_global_init();
-
-#elif defined(HAVE_LIBSSL)
- /*
-  * Initialize OpenSSL...
-  */
-
-  SSL_load_error_strings();
-  SSL_library_init();
-
- /*
-  * Using the current time is a dubious random seed, but on some systems
-  * it is the best we can do (on others, this seed isn't even used...)
-  */
-
-  CUPS_SRAND(time(NULL));
-
-  for (i = 0; i < sizeof(data); i ++)
-    data[i] = CUPS_RAND();
-
-  RAND_seed(data, sizeof(data));
-#endif /* HAVE_GNUTLS */
-}
-
-
-#ifdef HAVE_SSL
-/*
- * 'http_tls_read()' - Read from a SSL/TLS connection.
- */
-
-static int                             /* O - Bytes read */
-http_tls_read(http_t *http,            /* I - Connection to server */
-             char   *buf,              /* I - Buffer to store data */
-             int    len)               /* I - Length of buffer */
-{
-#  if defined(HAVE_LIBSSL)
-  return (SSL_read((SSL *)(http->tls), buf, len));
-
-#  elif defined(HAVE_GNUTLS)
-  ssize_t      result;                 /* Return value */
-
-
-  result = gnutls_record_recv(http->tls, buf, len);
-
-  if (result < 0 && !errno)
-  {
-   /*
-    * Convert GNU TLS error to errno value...
-    */
-
-    switch (result)
-    {
-      case GNUTLS_E_INTERRUPTED :
-         errno = EINTR;
-         break;
-
-      case GNUTLS_E_AGAIN :
-          errno = EAGAIN;
-          break;
-
-      default :
-          errno = EPIPE;
-          break;
-    }
-
-    result = -1;
-  }
-
-  return ((int)result);
-
-#  elif defined(HAVE_CDSASSL)
-  int          result;                 /* Return value */
-  OSStatus     error;                  /* Error info */
-  size_t       processed;              /* Number of bytes processed */
-
-
-  error = SSLRead(http->tls, buf, len, &processed);
-  DEBUG_printf(("6http_tls_read: error=%d, processed=%d", (int)error,
-                (int)processed));
-  switch (error)
-  {
-    case 0 :
-       result = (int)processed;
-       break;
-
-    case errSSLWouldBlock :
-       if (processed)
-         result = (int)processed;
-       else
-       {
-         result = -1;
-         errno  = EINTR;
-       }
-       break;
-
-    case errSSLClosedGraceful :
-    default :
-       if (processed)
-         result = (int)processed;
-       else
-       {
-         result = -1;
-         errno  = EPIPE;
-       }
-       break;
-  }
-
-  return (result);
-
-#  elif defined(HAVE_SSPISSL)
-  return _sspiRead((_sspi_struct_t*) http->tls, buf, len);
-#  endif /* HAVE_LIBSSL */
-}
-#endif /* HAVE_SSL */
-
-
-#ifdef HAVE_SSL
-/*
- * 'http_setup_ssl()' - Set up SSL/TLS support on a connection.
- */
-
-static int                             /* O - 0 on success, -1 on failure */
-http_setup_ssl(http_t *http)           /* I - Connection to server */
-{
-  char                 hostname[256],  /* Hostname */
-                       *hostptr;       /* Pointer into hostname */
-
-#  ifdef HAVE_LIBSSL
-  SSL_CTX              *context;       /* Context for encryption */
-  BIO                  *bio;           /* BIO data */
-  const char           *message = NULL;/* Error message */
-#  elif defined(HAVE_GNUTLS)
-  int                  status;         /* Status of handshake */
-  gnutls_certificate_client_credentials *credentials;
-                                       /* TLS credentials */
-#  elif defined(HAVE_CDSASSL)
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Pointer to library globals */
-  OSStatus             error;          /* Error code */
-  const char           *message = NULL;/* Error message */
-  cups_array_t         *credentials;   /* Credentials array */
-  cups_array_t         *names;         /* CUPS distinguished names */
-  CFArrayRef           dn_array;       /* CF distinguished names array */
-  CFIndex              count;          /* Number of credentials */
-  CFDataRef            data;           /* Certificate data */
-  int                  i;              /* Looping var */
-  http_credential_t    *credential;    /* Credential data */
-#  elif defined(HAVE_SSPISSL)
-  TCHAR                        username[256];  /* Username returned from GetUserName() */
-  TCHAR                        commonName[256];/* Common name for certificate */
-  DWORD                        dwSize;         /* 32 bit size */
-#  endif /* HAVE_LIBSSL */
-
-
-  DEBUG_printf(("7http_setup_ssl(http=%p)", http));
-
- /*
-  * Get the hostname to use for SSL...
-  */
-
-  if (httpAddrLocalhost(http->hostaddr))
-  {
-    strlcpy(hostname, "localhost", sizeof(hostname));
-  }
-  else
-  {
-   /*
-    * Otherwise make sure the hostname we have does not end in a trailing dot.
-    */
-
-    strlcpy(hostname, http->hostname, sizeof(hostname));
-    if ((hostptr = hostname + strlen(hostname) - 1) >= hostname &&
-        *hostptr == '.')
-      *hostptr = '\0';
-  }
-
-#  ifdef HAVE_LIBSSL
-  context = SSL_CTX_new(SSLv23_client_method());
-
-  SSL_CTX_set_options(context, SSL_OP_NO_SSLv2); /* Only use SSLv3 or TLS */
-
-  bio = BIO_new(_httpBIOMethods());
-  BIO_ctrl(bio, BIO_C_SET_FILE_PTR, 0, (char *)http);
-
-  http->tls = SSL_new(context);
-  SSL_set_bio(http->tls, bio, bio);
-
-#   ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
-  SSL_set_tlsext_host_name(http->tls, hostname);
-#   endif /* HAVE_SSL_SET_TLSEXT_HOST_NAME */
-
-  if (SSL_connect(http->tls) != 1)
-  {
-    unsigned long      error;  /* Error code */
-
-    while ((error = ERR_get_error()) != 0)
-    {
-      message = ERR_error_string(error, NULL);
-      DEBUG_printf(("8http_setup_ssl: %s", message));
-    }
-
-    SSL_CTX_free(context);
-    SSL_free(http->tls);
-    http->tls = NULL;
-
-#    ifdef WIN32
-    http->error  = WSAGetLastError();
-#    else
-    http->error  = errno;
-#    endif /* WIN32 */
-    http->status = HTTP_STATUS_ERROR;
-
-    if (!message)
-      message = _("Unable to establish a secure connection to host.");
-
-    _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, message, 1);
-
-    return (-1);
-  }
-
-#  elif defined(HAVE_GNUTLS)
-  credentials = (gnutls_certificate_client_credentials *)
-                    malloc(sizeof(gnutls_certificate_client_credentials));
-  if (credentials == NULL)
-  {
-    DEBUG_printf(("8http_setup_ssl: Unable to allocate credentials: %s",
-                  strerror(errno)));
-    http->error  = errno;
-    http->status = HTTP_STATUS_ERROR;
-    _cupsSetHTTPError(HTTP_STATUS_ERROR);
-
-    return (-1);
-  }
-
-  gnutls_certificate_allocate_credentials(credentials);
-
-  gnutls_init(&http->tls, GNUTLS_CLIENT);
-  gnutls_set_default_priority(http->tls);
-  gnutls_server_name_set(http->tls, GNUTLS_NAME_DNS, hostname,
-                         strlen(hostname));
-  gnutls_credentials_set(http->tls, GNUTLS_CRD_CERTIFICATE, *credentials);
-  gnutls_transport_set_ptr(http->tls, (gnutls_transport_ptr)http);
-  gnutls_transport_set_pull_function(http->tls, _httpReadGNUTLS);
-  gnutls_transport_set_push_function(http->tls, _httpWriteGNUTLS);
-
-  while ((status = gnutls_handshake(http->tls)) != GNUTLS_E_SUCCESS)
-  {
-    DEBUG_printf(("8http_setup_ssl: gnutls_handshake returned %d (%s)",
-                  status, gnutls_strerror(status)));
-
-    if (gnutls_error_is_fatal(status))
-    {
-      http->error  = EIO;
-      http->status = HTTP_STATUS_ERROR;
-
-      _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, gnutls_strerror(status), 0);
-
-      gnutls_deinit(http->tls);
-      gnutls_certificate_free_credentials(*credentials);
-      free(credentials);
-      http->tls = NULL;
-
-      return (-1);
-    }
-  }
-
-  http->tls_credentials = credentials;
-
-#  elif defined(HAVE_CDSASSL)
-  if ((http->tls = SSLCreateContext(kCFAllocatorDefault, kSSLClientSide,
-                                    kSSLStreamType)) == NULL)
-  {
-    DEBUG_puts("4http_setup_ssl: SSLCreateContext failed.");
-    http->error  = errno = ENOMEM;
-    http->status = HTTP_STATUS_ERROR;
-    _cupsSetHTTPError(HTTP_STATUS_ERROR);
-
-    return (-1);
-  }
-
-  error = SSLSetConnection(http->tls, http);
-  DEBUG_printf(("4http_setup_ssl: SSLSetConnection, error=%d", (int)error));
-
-  if (!error)
-  {
-    error = SSLSetIOFuncs(http->tls, _httpReadCDSA, _httpWriteCDSA);
-    DEBUG_printf(("4http_setup_ssl: SSLSetIOFuncs, error=%d", (int)error));
-  }
-
-  if (!error)
-  {
-    error = SSLSetSessionOption(http->tls, kSSLSessionOptionBreakOnServerAuth,
-                                true);
-    DEBUG_printf(("4http_setup_ssl: SSLSetSessionOption, error=%d",
-                  (int)error));
-  }
-
-  if (!error)
-  {
-    if (cg->client_cert_cb)
-    {
-      error = SSLSetSessionOption(http->tls,
-                                 kSSLSessionOptionBreakOnCertRequested, true);
-      DEBUG_printf(("4http_setup_ssl: kSSLSessionOptionBreakOnCertRequested, "
-                    "error=%d", (int)error));
-    }
-    else
-    {
-      error = http_set_credentials(http);
-      DEBUG_printf(("4http_setup_ssl: http_set_credentials, error=%d",
-                    (int)error));
-    }
-  }
-
- /*
-  * Let the server know which hostname/domain we are trying to connect to
-  * in case it wants to serve up a certificate with a matching common name.
-  */
-
-  if (!error)
-  {
-    error = SSLSetPeerDomainName(http->tls, hostname, strlen(hostname));
-
-    DEBUG_printf(("4http_setup_ssl: SSLSetPeerDomainName, error=%d",
-                  (int)error));
-  }
-
-  if (!error)
-  {
-    int done = 0;                      /* Are we done yet? */
-
-    while (!error && !done)
-    {
-      error = SSLHandshake(http->tls);
-
-      DEBUG_printf(("4http_setup_ssl: SSLHandshake returned %d.", (int)error));
-
-      switch (error)
-      {
-       case noErr :
-           done = 1;
-           break;
-
-       case errSSLWouldBlock :
-           error = noErr;              /* Force a retry */
-           usleep(1000);               /* in 1 millisecond */
-           break;
-
-       case errSSLServerAuthCompleted :
-           error = 0;
-           if (cg->server_cert_cb)
-           {
-             error = httpCopyCredentials(http, &credentials);
-             if (!error)
-             {
-               error = (cg->server_cert_cb)(http, http->tls, credentials,
-                                            cg->server_cert_data);
-               httpFreeCredentials(credentials);
-             }
-
-             DEBUG_printf(("4http_setup_ssl: Server certificate callback "
-                           "returned %d.", (int)error));
-           }
-           break;
-
-       case errSSLClientCertRequested :
-           error = 0;
-
-           if (cg->client_cert_cb)
-           {
-             names = NULL;
-             if (!(error = SSLCopyDistinguishedNames(http->tls, &dn_array)) &&
-                 dn_array)
-             {
-               if ((names = cupsArrayNew(NULL, NULL)) != NULL)
-               {
-                 for (i = 0, count = CFArrayGetCount(dn_array); i < count; i++)
-                 {
-                   data = (CFDataRef)CFArrayGetValueAtIndex(dn_array, i);
-
-                   if ((credential = malloc(sizeof(*credential))) != NULL)
-                   {
-                     credential->datalen = CFDataGetLength(data);
-                     if ((credential->data = malloc(credential->datalen)))
-                     {
-                       memcpy((void *)credential->data, CFDataGetBytePtr(data),
-                              credential->datalen);
-                       cupsArrayAdd(names, credential);
-                     }
-                     else
-                       free(credential);
-                   }
-                 }
-               }
-
-               CFRelease(dn_array);
-             }
-
-             if (!error)
-             {
-               error = (cg->client_cert_cb)(http, http->tls, names,
-                                            cg->client_cert_data);
-
-               DEBUG_printf(("4http_setup_ssl: Client certificate callback "
-                             "returned %d.", (int)error));
-             }
-
-             httpFreeCredentials(names);
-           }
-           break;
-
-       case errSSLUnknownRootCert :
-           message = _("Unable to establish a secure connection to host "
-                       "(untrusted certificate).");
-           break;
-
-       case errSSLNoRootCert :
-           message = _("Unable to establish a secure connection to host "
-                       "(self-signed certificate).");
-           break;
-
-       case errSSLCertExpired :
-           message = _("Unable to establish a secure connection to host "
-                       "(expired certificate).");
-           break;
-
-       case errSSLCertNotYetValid :
-           message = _("Unable to establish a secure connection to host "
-                       "(certificate not yet valid).");
-           break;
-
-       case errSSLHostNameMismatch :
-           message = _("Unable to establish a secure connection to host "
-                       "(host name mismatch).");
-           break;
-
-       case errSSLXCertChainInvalid :
-           message = _("Unable to establish a secure connection to host "
-                       "(certificate chain invalid).");
-           break;
-
-       case errSSLConnectionRefused :
-           message = _("Unable to establish a secure connection to host "
-                       "(peer dropped connection before responding).");
-           break;
-
-       default :
-           break;
-      }
-    }
-  }
-
-  if (error)
-  {
-    http->error  = error;
-    http->status = HTTP_STATUS_ERROR;
-    errno        = ECONNREFUSED;
-
-    CFRelease(http->tls);
-    http->tls = NULL;
-
-   /*
-    * If an error string wasn't set by the callbacks use a generic one...
-    */
-
-    if (!message)
-#ifdef HAVE_CSSMERRORSTRING
-      message = cssmErrorString(error);
-#else
-      message = _("Unable to establish a secure connection to host.");
-#endif /* HAVE_CSSMERRORSTRING */
-
-    _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, message, 1);
-
-    return (-1);
-  }
-
-#  elif defined(HAVE_SSPISSL)
-  http->tls = _sspiAlloc();
-
-  if (!http->tls)
-  {
-    _cupsSetHTTPError(HTTP_STATUS_ERROR);
-    return (-1);
-  }
-
-  http->tls->sock = http->fd;
-  dwSize          = sizeof(username) / sizeof(TCHAR);
-  GetUserName(username, &dwSize);
-  _sntprintf_s(commonName, sizeof(commonName) / sizeof(TCHAR),
-               sizeof(commonName) / sizeof(TCHAR), TEXT("CN=%s"), username);
-
-  if (!_sspiGetCredentials(http->tls_credentials, L"ClientContainer",
-                           commonName, FALSE))
-  {
-    _sspiFree(http->tls_credentials);
-    http->tls_credentials = NULL;
-
-    http->error  = EIO;
-    http->status = HTTP_STATUS_ERROR;
-
-    _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI,
-                  _("Unable to establish a secure connection to host."), 1);
-
-    return (-1);
-  }
-
-  _sspiSetAllowsAnyRoot(http->tls_credentials, TRUE);
-  _sspiSetAllowsExpiredCerts(http->tls_credentials, TRUE);
-
-  if (!_sspiConnect(http->tls_credentials, hostname))
-  {
-    _sspiFree(http->tls_credentials);
-    http->tls_credentials = NULL;
-
-    http->error  = EIO;
-    http->status = HTTP_STATUS_ERROR;
-
-    _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI,
-                  _("Unable to establish a secure connection to host."), 1);
-
-    return (-1);
-  }
-#  endif /* HAVE_CDSASSL */
-
-  return (0);
-}
-
-
-/*
- * 'http_shutdown_ssl()' - Shut down SSL/TLS on a connection.
- */
-
-static void
-http_shutdown_ssl(http_t *http)                /* I - Connection to server */
-{
-#  ifdef HAVE_LIBSSL
-  SSL_CTX      *context;               /* Context for encryption */
-
-  context = SSL_get_SSL_CTX(http->tls);
-
-  SSL_shutdown(http->tls);
-  SSL_CTX_free(context);
-  SSL_free(http->tls);
-
-#  elif defined(HAVE_GNUTLS)
-  gnutls_certificate_client_credentials *credentials;
-                                       /* TLS credentials */
-
-  credentials = (gnutls_certificate_client_credentials *)(http->tls_credentials);
-
-  gnutls_bye(http->tls, GNUTLS_SHUT_RDWR);
-  gnutls_deinit(http->tls);
-  gnutls_certificate_free_credentials(*credentials);
-  free(credentials);
-
-#  elif defined(HAVE_CDSASSL)
-  while (SSLClose(http->tls) == errSSLWouldBlock)
-    usleep(1000);
-
-  CFRelease(http->tls);
-
-  if (http->tls_credentials)
-    CFRelease(http->tls_credentials);
-
-#  elif defined(HAVE_SSPISSL)
-  _sspiFree(http->tls_credentials);
-#  endif /* HAVE_LIBSSL */
-
-  http->tls             = NULL;
-  http->tls_credentials = NULL;
-}
-#endif /* HAVE_SSL */
-
-
-#ifdef HAVE_SSL
-/*
- * 'http_write_ssl()' - Write to a SSL/TLS connection.
- */
-
-static int                             /* O - Bytes written */
-http_write_ssl(http_t     *http,       /* I - Connection to server */
-              const char *buf,         /* I - Buffer holding data */
-              int        len)          /* I - Length of buffer */
-{
-  ssize_t      result;                 /* Return value */
-
-
-  DEBUG_printf(("2http_write_ssl(http=%p, buf=%p, len=%d)", http, buf, len));
-
-#  if defined(HAVE_LIBSSL)
-  result = SSL_write((SSL *)(http->tls), buf, len);
-
-#  elif defined(HAVE_GNUTLS)
-  result = gnutls_record_send(http->tls, buf, len);
-
-  if (result < 0 && !errno)
-  {
-   /*
-    * Convert GNU TLS error to errno value...
-    */
-
-    switch (result)
-    {
-      case GNUTLS_E_INTERRUPTED :
-         errno = EINTR;
-         break;
-
-      case GNUTLS_E_AGAIN :
-          errno = EAGAIN;
-          break;
-
-      default :
-          errno = EPIPE;
-          break;
-    }
-
-    result = -1;
-  }
-
-#  elif defined(HAVE_CDSASSL)
-  OSStatus     error;                  /* Error info */
-  size_t       processed;              /* Number of bytes processed */
-
-
-  error = SSLWrite(http->tls, buf, len, &processed);
-
-  switch (error)
-  {
-    case 0 :
-       result = (int)processed;
-       break;
-
-    case errSSLWouldBlock :
-       if (processed)
-         result = (int)processed;
-       else
-       {
-         result = -1;
-         errno  = EINTR;
-       }
-       break;
-
-    case errSSLClosedGraceful :
-    default :
-       if (processed)
-         result = (int)processed;
-       else
-       {
-         result = -1;
-         errno  = EPIPE;
-       }
-       break;
-  }
-#  elif defined(HAVE_SSPISSL)
-  return _sspiWrite((_sspi_struct_t *)http->tls, (void *)buf, len);
-#  endif /* HAVE_LIBSSL */
-
-  DEBUG_printf(("3http_write_ssl: Returning %d.", (int)result));
-
-  return ((int)result);
-}
-#endif /* HAVE_SSL */
-
-
-/*
- * 'http_tls_pending()' - Return the number of pending TLS-encrypted bytes.
- */
-
-static size_t
-http_tls_pending(http_t *http)         /* I - HTTP connection */
-{
-  if (http->tls && usessl)
-  {
-#  ifdef HAVE_LIBSSL
-    if (SSL_pending(http->tls))
-    {
-      DEBUG_puts("5_httpWait: Return 1 since there is pending SSL data.");
-      return (1);
-    }
-
-#  elif defined(HAVE_GNUTLS)
-    if (gnutls_record_check_pending(http->tls))
-    {
-      DEBUG_puts("5_httpWait: Return 1 since there is pending SSL data.");
-      return (1);
-    }
-
-#  elif defined(HAVE_CDSASSL)
-    size_t bytes;                      /* Bytes that are available */
-
-    if (!SSLGetBufferedReadSize(http->tls, &bytes) &&
-        bytes > 0)
-    {
-      DEBUG_puts("5_httpWait: Return 1 since there is pending SSL data.");
-      return (1);
-    }
-#  endif /* HAVE_LIBSSL */
-}
-
-
-#if defined(HAVE_SSL) && defined(HAVE_LIBSSL)
-/*
- * 'http_bio_ctrl()' - Control the HTTP connection.
- */
-
-static long                            /* O - Result/data */
-http_bio_ctrl(BIO  *h,                 /* I - BIO data */
-              int  cmd,                        /* I - Control command */
-             long arg1,                /* I - First argument */
-             void *arg2)               /* I - Second argument */
-{
-  switch (cmd)
-  {
-    default :
-        return (0);
-
-    case BIO_CTRL_RESET :
-        h->ptr = NULL;
-       return (0);
-
-    case BIO_C_SET_FILE_PTR :
-        h->ptr  = arg2;
-       h->init = 1;
-       return (1);
-
-    case BIO_C_GET_FILE_PTR :
-        if (arg2)
-       {
-         *((void **)arg2) = h->ptr;
-         return (1);
-       }
-       else
-         return (0);
-
-    case BIO_CTRL_DUP :
-    case BIO_CTRL_FLUSH :
-        return (1);
-  }
-}
-
-
-/*
- * 'http_bio_free()' - Free OpenSSL data.
- */
-
-static int                             /* O - 1 on success, 0 on failure */
-http_bio_free(BIO *h)                  /* I - BIO data */
-{
-  if (!h)
-    return (0);
-
-  if (h->shutdown)
-  {
-    h->init  = 0;
-    h->flags = 0;
-  }
-
-  return (1);
-}
-
-
-/*
- * 'http_bio_new()' - Initialize an OpenSSL BIO structure.
- */
-
-static int                             /* O - 1 on success, 0 on failure */
-http_bio_new(BIO *h)                   /* I - BIO data */
-{
-  if (!h)
-    return (0);
-
-  h->init  = 0;
-  h->num   = 0;
-  h->ptr   = NULL;
-  h->flags = 0;
-
-  return (1);
-}
-
-
-/*
- * 'http_bio_puts()' - Send a string for OpenSSL.
- */
-
-static int                             /* O - Bytes written */
-http_bio_puts(BIO        *h,           /* I - BIO data */
-              const char *str)         /* I - String to write */
-{
-#ifdef WIN32
-  return (send(((http_t *)h->ptr)->fd, str, (int)strlen(str), 0));
-#else
-  return (send(((http_t *)h->ptr)->fd, str, strlen(str), 0));
-#endif /* WIN32 */
-}
-
-
-/*
- * 'http_bio_read()' - Read data for OpenSSL.
- */
-
-static int                             /* O - Bytes read */
-http_bio_read(BIO  *h,                 /* I - BIO data */
-              char *buf,               /* I - Buffer */
-             int  size)                /* I - Number of bytes to read */
-{
-  http_t       *http;                  /* HTTP connection */
-
-
-  http = (http_t *)h->ptr;
-
-  if (!http->blocking)
-  {
-   /*
-    * Make sure we have data before we read...
-    */
-
-    while (!_httpWait(http, http->wait_value, 0))
-    {
-      if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
-       continue;
-
-#ifdef WIN32
-      http->error = WSAETIMEDOUT;
-#else
-      http->error = ETIMEDOUT;
-#endif /* WIN32 */
-
-      return (-1);
-    }
-  }
-
-  return (recv(http->fd, buf, size, 0));
-}
-
-
-/*
- * 'http_bio_write()' - Write data for OpenSSL.
- */
-
-static int                             /* O - Bytes written */
-http_bio_write(BIO        *h,          /* I - BIO data */
-               const char *buf,                /* I - Buffer to write */
-              int        num)          /* I - Number of bytes to write */
-{
-  return (send(((http_t *)h->ptr)->fd, buf, num, 0));
-}
-#endif /* HAVE_SSL && HAVE_LIBSSL */
-
-
-/*
- * 'cupsdEndTLS()' - Shutdown a secure session with the client.
- */
-
-int                                    /* O - 1 on success, 0 on error */
-cupsdEndTLS(cupsd_client_t *con)       /* I - Client connection */
-{
-  SSL_CTX      *context;               /* Context for encryption */
-  unsigned long        error;                  /* Error code */
-  int          status;                 /* Return status */
-
-
-  context = SSL_get_SSL_CTX(con->http.tls);
-
-  switch (SSL_shutdown(con->http.tls))
-  {
-    case 1 :
-       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "SSL shutdown successful!");
-       status = 1;
-       break;
-
-    case -1 :
-       cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Fatal error during SSL shutdown!");
-
-    default :
-       while ((error = ERR_get_error()) != 0)
-         cupsdLogMessage(CUPSD_LOG_ERROR, "SSL shutdown failed: %s",
-                         ERR_error_string(error, NULL));
-       status = 0;
-       break;
-  }
-
-  SSL_CTX_free(context);
-  SSL_free(con->http.tls);
-  con->http.tls = NULL;
-
-  return (status);
-}
-
-
-/*
- * 'cupsdStartTLS()' - Start a secure session with the client.
- */
-
-int                                    /* O - 1 on success, 0 on error */
-cupsdStartTLS(cupsd_client_t *con)     /* I - Client connection */
-{
-  SSL_CTX      *context;               /* Context for encryption */
-  BIO          *bio;                   /* BIO data */
-  unsigned long        error;                  /* Error code */
-
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "[Client %d] Encrypting connection.",
-                  con->http.fd);
-
- /*
-  * Verify that we have a certificate...
-  */
-
-  if (access(ServerKey, 0) || access(ServerCertificate, 0))
-  {
-   /*
-    * Nope, make a self-signed certificate...
-    */
-
-    if (!make_certificate(con))
-      return (0);
-  }
-
- /*
-  * Create the SSL context and accept the connection...
-  */
-
-  context = SSL_CTX_new(SSLv23_server_method());
-
-  SSL_CTX_set_options(context, SSL_OP_NO_SSLv2); /* Only use SSLv3 or TLS */
-  if (SSLOptions & CUPSD_SSL_NOEMPTY)
-    SSL_CTX_set_options(context, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
-  SSL_CTX_use_PrivateKey_file(context, ServerKey, SSL_FILETYPE_PEM);
-  SSL_CTX_use_certificate_chain_file(context, ServerCertificate);
-
-  bio = BIO_new(_httpBIOMethods());
-  BIO_ctrl(bio, BIO_C_SET_FILE_PTR, 0, (char *)HTTP(con));
-
-  con->http.tls = SSL_new(context);
-  SSL_set_bio(con->http.tls, bio, bio);
-
-  if (SSL_accept(con->http.tls) != 1)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to encrypt connection from %s.",
-                    con->http.hostname);
-
-    while ((error = ERR_get_error()) != 0)
-      cupsdLogMessage(CUPSD_LOG_ERROR, "%s", ERR_error_string(error, NULL));
-
-    SSL_CTX_free(context);
-    SSL_free(con->http.tls);
-    con->http.tls = NULL;
-    return (0);
-  }
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG, "Connection from %s now encrypted.",
-                  con->http.hostname);
-
-  return (1);
-}
-
-
-/*
- * 'make_certificate()' - Make a self-signed SSL/TLS certificate.
- */
-
-static int                             /* O - 1 on success, 0 on failure */
-make_certificate(cupsd_client_t *con)  /* I - Client connection */
-{
-#ifdef HAVE_WAITPID
-  int          pid,                    /* Process ID of command */
-               status;                 /* Status of command */
-  char         command[1024],          /* Command */
-               *argv[12],              /* Command-line arguments */
-               *envp[MAX_ENV + 1],     /* Environment variables */
-               infofile[1024],         /* Type-in information for cert */
-               seedfile[1024];         /* Random number seed file */
-  int          envc,                   /* Number of environment variables */
-               bytes;                  /* Bytes written */
-  cups_file_t  *fp;                    /* Seed/info file */
-  int          infofd;                 /* Info file descriptor */
-
-
- /*
-  * Run the "openssl" command to seed the random number generator and
-  * generate a self-signed certificate that is good for 10 years:
-  *
-  *     openssl rand -rand seedfile 1
-  *
-  *     openssl req -new -x509 -keyout ServerKey \
-  *             -out ServerCertificate -days 3650 -nodes
-  *
-  * The seeding step is crucial in ensuring that the openssl command
-  * does not block on systems without sufficient entropy...
-  */
-
-  if (!cupsFileFind("openssl", getenv("PATH"), 1, command, sizeof(command)))
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "No SSL certificate and openssl command not found!");
-    return (0);
-  }
-
-  if (access("/dev/urandom", 0))
-  {
-   /*
-    * If the system doesn't provide /dev/urandom, then any random source
-    * will probably be blocking-style, so generate some random data to
-    * use as a seed for the certificate.  Note that we have already
-    * seeded the random number generator in cupsdInitCerts()...
-    */
-
-    cupsdLogMessage(CUPSD_LOG_INFO,
-                    "Seeding the random number generator...");
-
-   /*
-    * Write the seed file...
-    */
-
-    if ((fp = cupsTempFile2(seedfile, sizeof(seedfile))) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create seed file %s - %s",
-                      seedfile, strerror(errno));
-      return (0);
-    }
-
-    for (bytes = 0; bytes < 262144; bytes ++)
-      cupsFilePutChar(fp, CUPS_RAND());
-
-    cupsFileClose(fp);
-
-   /*
-    * Run the openssl command to seed its random number generator...
-    */
-
-    argv[0] = "openssl";
-    argv[1] = "rand";
-    argv[2] = "-rand";
-    argv[3] = seedfile;
-    argv[4] = "1";
-    argv[5] = NULL;
-
-    envc = cupsdLoadEnv(envp, MAX_ENV);
-    envp[envc] = NULL;
-
-    if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, -1, 1, NULL,
-                           NULL, &pid))
-    {
-      unlink(seedfile);
-      return (0);
-    }
-
-    while (waitpid(pid, &status, 0) < 0)
-      if (errno != EINTR)
-      {
-       status = 1;
-       break;
-      }
-
-    cupsdFinishProcess(pid, command, sizeof(command), NULL);
-
-   /*
-    * Remove the seed file, as it is no longer needed...
-    */
-
-    unlink(seedfile);
-
-    if (status)
-    {
-      if (WIFEXITED(status))
-       cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Unable to seed random number generator - "
-                       "the openssl command stopped with status %d!",
-                       WEXITSTATUS(status));
-      else
-       cupsdLogMessage(CUPSD_LOG_ERROR,
-                       "Unable to seed random number generator - "
-                       "the openssl command crashed on signal %d!",
-                       WTERMSIG(status));
-
-      return (0);
-    }
-  }
-
- /*
-  * Create a file with the certificate information fields...
-  *
-  * Note: This assumes that the default questions are asked by the openssl
-  * command...
-  */
-
-  if ((fp = cupsTempFile2(infofile, sizeof(infofile))) == NULL)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to create certificate information file %s - %s",
-                    infofile, strerror(errno));
-    return (0);
-  }
-
-  cupsFilePrintf(fp, ".\n.\n.\n%s\n.\n%s\n%s\n",
-                 ServerName, ServerName, ServerAdmin);
-  cupsFileClose(fp);
-
-  cupsdLogMessage(CUPSD_LOG_INFO,
-                  "Generating SSL server key and certificate...");
-
-  argv[0]  = "openssl";
-  argv[1]  = "req";
-  argv[2]  = "-new";
-  argv[3]  = "-x509";
-  argv[4]  = "-keyout";
-  argv[5]  = ServerKey;
-  argv[6]  = "-out";
-  argv[7]  = ServerCertificate;
-  argv[8]  = "-days";
-  argv[9]  = "3650";
-  argv[10] = "-nodes";
-  argv[11] = NULL;
-
-  cupsdLoadEnv(envp, MAX_ENV);
-
-  infofd = open(infofile, O_RDONLY);
-
-  if (!cupsdStartProcess(command, argv, envp, infofd, -1, -1, -1, -1, 1, NULL,
-                         NULL, &pid))
-  {
-    close(infofd);
-    unlink(infofile);
-    return (0);
-  }
-
-  close(infofd);
-  unlink(infofile);
-
-  while (waitpid(pid, &status, 0) < 0)
-    if (errno != EINTR)
-    {
-      status = 1;
-      break;
-    }
-
-  cupsdFinishProcess(pid, command, sizeof(command), NULL);
-
-  if (status)
-  {
-    if (WIFEXITED(status))
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to create SSL server key and certificate - "
-                     "the openssl command stopped with status %d!",
-                     WEXITSTATUS(status));
-    else
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to create SSL server key and certificate - "
-                     "the openssl command crashed on signal %d!",
-                     WTERMSIG(status));
-  }
-  else
-  {
-    cupsdLogMessage(CUPSD_LOG_INFO, "Created SSL server key file \"%s\"...",
-                   ServerKey);
-    cupsdLogMessage(CUPSD_LOG_INFO,
-                    "Created SSL server certificate file \"%s\"...",
-                   ServerCertificate);
-  }
-
-  return (!status);
-
-#else
-  return (0);
-#endif /* HAVE_WAITPID */
-}
-
-
-/*
- * End of "$Id$".
- */
index 9bbc729edf19a661e4b73921482ad58acb9618e8..005662183e4d4318896090925b3693541d105e4c 100644 (file)
@@ -8,7 +8,7 @@
 
 <H1 CLASS="title">Software License Agreement</H1>
 
-<P ALIGN="CENTER">Copyright 2007-2012 by Apple Inc.<BR>
+<P ALIGN="CENTER">Copyright 2007-2013 by Apple Inc.<BR>
 1 Infinite Loop<BR>
 Cupertino, CA 95014 USA<BR>
 <BR>
@@ -16,10 +16,7 @@ WWW: <A HREF="http://www.cups.org/">http://www.cups.org/</A>
 
 <H2 CLASS="title"><A NAME="INTRO">Introduction</A></H2>
 
-<P>CUPS<SUP>TM</SUP> is provided under the GNU General Public License ("GPL")
-and GNU Library General Public License ("LGPL"), Version 2, with exceptions for
-Apple operating systems and the OpenSSL toolkit. A copy of the exceptions and
-licenses follow this introduction.</P>
+<P>CUPS<SUP>TM</SUP> is provided under the GNU General Public License ("GPL") and GNU Library General Public License ("LGPL"), Version 2, with an exception for Apple operating systems. A copy of the exception and licenses follow this introduction.</P>
 
 <P>The GNU LGPL applies to the CUPS and CUPS Imaging libraries located in the
 "cups" and "filter" subdirectories of the CUPS source distribution and the files
@@ -59,7 +56,7 @@ for your application, driver, or filter.</P>
 <H2 CLASS="title"><A NAME="EXCEPTIONS">License Exceptions</A></H2>
 
 <P>In addition, as the copyright holder of CUPS, Apple Inc. grants
-the following special exceptions:</P>
+the following special exception:</P>
 
 <OL>
 
@@ -111,20 +108,9 @@ the following special exceptions:</P>
 
        </OL>
 
-       <LI><B>OpenSSL Toolkit License Exception</B>;
-
-       <OL TYPE="a">
-
-               <LI>Apple Inc. explicitly allows the
-               compilation and distribution of the CUPS
-               software with the OpenSSL Toolkit.</LI>
-
-       </OL>
-
 </OL>
 
-<P>No developer is required to provide these exceptions in a
-derived work.</P>
+<P>No developer is required to provide this exception in a derived work.</P>
 
 
 <H2 CLASS="title"><A NAME="KERBEROS">Kerberos Support Code</A></H2>
index 8011f872c98a1ba33873036538d9ef7241acfd74..55ebe514d0f8cfe826c95a3a8db1f894aa0d8296 100644 (file)
@@ -418,10 +418,6 @@ int                                        /* O - 1 if partial close, 0 if fully closed */
 cupsdCloseClient(cupsd_client_t *con)  /* I - Client to close */
 {
   int          partial;                /* Do partial close for SSL? */
-#ifdef HAVE_LIBSSL
-#elif defined(HAVE_GNUTLS)
-#  elif defined(HAVE_CDSASSL)
-#endif /* HAVE_LIBSSL */
 
 
   cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing connection.");
index eb26aff8edeb825ab11b3197ca662eff1aa7b3a1..f37bbe4cb028b3187475bc3476a366be55868cfd 100644 (file)
@@ -144,9 +144,9 @@ static const cupsd_var_t    cupsfiles_vars[] =
   { "ServerBin",               &ServerBin,             CUPSD_VARTYPE_PATHNAME },
 #ifdef HAVE_SSL
   { "ServerCertificate",       &ServerCertificate,     CUPSD_VARTYPE_PATHNAME },
-#  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
+#  ifdef HAVE_GNUTLS
   { "ServerKey",               &ServerKey,             CUPSD_VARTYPE_PATHNAME },
-#  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
+#  endif /* HAVE_GNUTLS */
 #endif /* HAVE_SSL */
   { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_PATHNAME },
   { "SMBConfigFile",           &SMBConfigFile,         CUPSD_VARTYPE_STRING },
@@ -1069,7 +1069,7 @@ cupsdReadConfiguration(void)
       (FatalErrors & CUPSD_FATAL_PERMISSIONS))
     return (0);
 
-#  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
+#  ifdef HAVE_GNUTLS
   if (ServerKey[0] != '/')
     cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey);
 
@@ -1077,7 +1077,7 @@ cupsdReadConfiguration(void)
       cupsdCheckPermissions(ServerKey, NULL, 0600, RunUser, Group, 0, 0) < 0 &&
       (FatalErrors & CUPSD_FATAL_PERMISSIONS))
     return (0);
-#  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
+#  endif /* HAVE_GNUTLS */
 #endif /* HAVE_SSL */
 
  /*
index 034e7211acb7115b29c2b74590ec59e05214683c..e9e0fd80445b286e08f671fe57aa9f317a96766b 100644 (file)
@@ -238,10 +238,10 @@ VAR const char            **MimeTypes             VALUE(NULL);
 #ifdef HAVE_SSL
 VAR char               *ServerCertificate      VALUE(NULL);
                                        /* Server certificate file */
-#  if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
+#  ifdef HAVE_GNUTLS
 VAR char               *ServerKey              VALUE(NULL);
                                        /* Server key file */
-#  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
+#  endif /* HAVE_GNUTLS */
 VAR int                        SSLOptions              VALUE(CUPSD_SSL_NONE);
                                        /* SSL/TLS options */
 #endif /* HAVE_SSL */
index b4ed189138a6b4b7e3490502d873be7c9d8c95a3..5e4d75a601413761119c4ac8ceb552b34ca8911a 100644 (file)
 
 /* #undef HAVE_CDSASSL */
 /* #undef HAVE_GNUTLS */
-/* #undef HAVE_LIBSSL */
 #define HAVE_SSPISSL
 #define HAVE_SSL
 
 
-/*
- * Do we have the SSL_set_tlsext_host_name function?
- */
-
-/* #undef HAVE_SSL_SET_TLSEXT_HOST_NAME */
-
-
 /*
  * What Security framework headers do we have?
  */
index 40c2b9418dfa21704250cf0dfe7adf6c7696c61a..1a4afdda743c4ea7d0ab6627be2e01c45c06e968 100644 (file)
 /* Begin PBXFileReference section */
                270B267D17F5C06700C8A3A9 /* tls-darwin.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-darwin.c"; path = "../cups/tls-darwin.c"; sourceTree = "<group>"; };
                270B267E17F5C06700C8A3A9 /* tls-gnutls.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-gnutls.c"; path = "../cups/tls-gnutls.c"; sourceTree = "<group>"; };
-               270B267F17F5C06700C8A3A9 /* tls-openssl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-openssl.c"; path = "../cups/tls-openssl.c"; sourceTree = "<group>"; };
                270B268017F5C5D600C8A3A9 /* sspi-private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "sspi-private.h"; path = "../cups/sspi-private.h"; sourceTree = "<group>"; };
                270B268117F5C5D600C8A3A9 /* tls-sspi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-sspi.c"; path = "../cups/tls-sspi.c"; sourceTree = "<group>"; };
                270CCDA7135E3C9E00007BE2 /* testmime */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testmime; sourceTree = BUILT_PRODUCTS_DIR; };
                                72220F05133305BB00FCA411 /* thread.c */,
                                270B267D17F5C06700C8A3A9 /* tls-darwin.c */,
                                270B267E17F5C06700C8A3A9 /* tls-gnutls.c */,
-                               270B267F17F5C06700C8A3A9 /* tls-openssl.c */,
                                270B268117F5C5D600C8A3A9 /* tls-sspi.c */,
                                270B268017F5C5D600C8A3A9 /* sspi-private.h */,
                                72220F06133305BB00FCA411 /* transcode.c */,
index 43a895432bf5231f50cda2703bf25b74242b7398..5140027da8a0e7464b6da585a96ec967dbcbfadf 100644 (file)
 
 #define HAVE_CDSASSL 1
 /* #undef HAVE_GNUTLS */
-/* #undef HAVE_LIBSSL */
 #define HAVE_SSL 1
 
 
-/*
- * Do we have the SSL_set_tlsext_host_name function?
- */
-
-/* #undef HAVE_SSL_SET_TLSEXT_HOST_NAME */
-
-
 /*
  * What Security framework headers do we have?
  */