Blame SOURCES/0015-curl-7.29.0-7fc9325a.patch

c260e0
From a7b1ea3537b30450ad82d2c64d31dcecaed60fca Mon Sep 17 00:00:00 2001
c260e0
From: Gergely Nagy <ngg@tresorit.com>
c260e0
Date: Thu, 19 Sep 2013 15:17:13 +0200
c260e0
Subject: [PATCH 1/9] SSL: protocol version can be specified more precisely
c260e0
c260e0
CURL_SSLVERSION_TLSv1_0, CURL_SSLVERSION_TLSv1_1,
c260e0
CURL_SSLVERSION_TLSv1_2 enum values are added to force exact TLS version
c260e0
(CURL_SSLVERSION_TLSv1 means TLS 1.x).
c260e0
c260e0
axTLS:
c260e0
axTLS only supports TLS 1.0 and 1.1 but it cannot be set that only one
c260e0
of these should be used, so we don't allow the new enum values.
c260e0
c260e0
darwinssl:
c260e0
Added support for the new enum values.
c260e0
c260e0
SChannel:
c260e0
Added support for the new enum values.
c260e0
c260e0
CyaSSL:
c260e0
Added support for the new enum values.
c260e0
Bug: The original CURL_SSLVERSION_TLSv1 value enables only TLS 1.0 (it
c260e0
did the same before this commit), because CyaSSL cannot be configured to
c260e0
use TLS 1.0-1.2.
c260e0
c260e0
GSKit:
c260e0
GSKit doesn't seem to support TLS 1.1 and TLS 1.2, so we do not allow
c260e0
those values.
c260e0
Bugfix: There was a typo that caused wrong SSL versions to be passed to
c260e0
GSKit.
c260e0
c260e0
NSS:
c260e0
TLS minor version cannot be set, so we don't allow the new enum values.
c260e0
c260e0
QsoSSL:
c260e0
TLS minor version cannot be set, so we don't allow the new enum values.
c260e0
c260e0
OpenSSL:
c260e0
Added support for the new enum values.
c260e0
Bugfix: The original CURL_SSLVERSION_TLSv1 value enabled only TLS 1.0,
c260e0
now it enables 1.0-1.2.
c260e0
c260e0
Command-line tool:
c260e0
Added command line options for the new values.
c260e0
c260e0
[upstream commit ad34a2d5c87c7f4b14e8dded34569395de0d8c5b]
c260e0
---
c260e0
 docs/libcurl/curl_easy_setopt.3  |    8 +++++-
c260e0
 docs/libcurl/symbols-in-versions |    3 ++
c260e0
 include/curl/curl.h              |    5 +++-
c260e0
 lib/axtls.c                      |    3 +-
c260e0
 lib/curl_darwinssl.c             |   34 +++++++++++++++++++++++++
c260e0
 lib/curl_schannel.c              |    9 ++++++
c260e0
 lib/cyassl.c                     |   13 +++++++++-
c260e0
 lib/nss.c                        |    6 ++++
c260e0
 lib/qssl.c                       |    6 ++++
c260e0
 lib/ssluse.c                     |   51 +++++++++++++++++++++++++++----------
c260e0
 packages/OS400/curl.inc.in       |    6 ++++
c260e0
 src/tool_getparam.c              |   25 ++++++++++++++++--
c260e0
 src/tool_setopt.c                |    3 ++
c260e0
 13 files changed, 151 insertions(+), 21 deletions(-)
c260e0
c260e0
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
c260e0
index 3d31aef..92db8f4 100644
c260e0
--- a/docs/libcurl/curl_easy_setopt.3
c260e0
+++ b/docs/libcurl/curl_easy_setopt.3
c260e0
@@ -2219,11 +2219,17 @@ The default action. This will attempt to figure out the remote SSL protocol
c260e0
 version, i.e. either SSLv3 or TLSv1 (but not SSLv2, which became disabled
c260e0
 by default with 7.18.1).
c260e0
 .IP CURL_SSLVERSION_TLSv1
c260e0
-Force TLSv1
c260e0
+Force TLSv1.x
c260e0
 .IP CURL_SSLVERSION_SSLv2
c260e0
 Force SSLv2
c260e0
 .IP CURL_SSLVERSION_SSLv3
c260e0
 Force SSLv3
c260e0
+.IP CURL_SSLVERSION_TLSv1_0
c260e0
+Force TLSv1.0
c260e0
+.IP CURL_SSLVERSION_TLSv1_1
c260e0
+Force TLSv1.1
c260e0
+.IP CURL_SSLVERSION_TLSv1_2
c260e0
+Force TLSv1.2
c260e0
 .RE
c260e0
 .IP CURLOPT_SSL_VERIFYPEER
c260e0
 Pass a long as parameter. By default, curl assumes a value of 1.
c260e0
diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
c260e0
index 37b5e27..57fa6eb 100644
c260e0
--- a/docs/libcurl/symbols-in-versions
c260e0
+++ b/docs/libcurl/symbols-in-versions
c260e0
@@ -678,6 +678,9 @@ CURL_SSLVERSION_DEFAULT         7.9.2
c260e0
 CURL_SSLVERSION_SSLv2           7.9.2
c260e0
 CURL_SSLVERSION_SSLv3           7.9.2
c260e0
 CURL_SSLVERSION_TLSv1           7.9.2
c260e0
+CURL_SSLVERSION_TLSv1_0         7.33.0
c260e0
+CURL_SSLVERSION_TLSv1_1         7.33.0
c260e0
+CURL_SSLVERSION_TLSv1_2         7.33.0
c260e0
 CURL_TIMECOND_IFMODSINCE        7.9.7
c260e0
 CURL_TIMECOND_IFUNMODSINCE      7.9.7
c260e0
 CURL_TIMECOND_LASTMOD           7.9.7
c260e0
diff --git a/include/curl/curl.h b/include/curl/curl.h
c260e0
index 80e4cf5..8e548e3 100644
c260e0
--- a/include/curl/curl.h
c260e0
+++ b/include/curl/curl.h
c260e0
@@ -1625,9 +1625,12 @@ enum CURL_NETRC_OPTION {
c260e0
 
c260e0
 enum {
c260e0
   CURL_SSLVERSION_DEFAULT,
c260e0
-  CURL_SSLVERSION_TLSv1,
c260e0
+  CURL_SSLVERSION_TLSv1, /* TLS 1.x */
c260e0
   CURL_SSLVERSION_SSLv2,
c260e0
   CURL_SSLVERSION_SSLv3,
c260e0
+  CURL_SSLVERSION_TLSv1_0,
c260e0
+  CURL_SSLVERSION_TLSv1_1,
c260e0
+  CURL_SSLVERSION_TLSv1_2,
c260e0
 
c260e0
   CURL_SSLVERSION_LAST /* never use, keep last */
c260e0
 };
c260e0
diff --git a/lib/axtls.c b/lib/axtls.c
c260e0
index d512950..68794b5 100644
c260e0
--- a/lib/axtls.c
c260e0
+++ b/lib/axtls.c
c260e0
@@ -169,7 +169,8 @@ Curl_axtls_connect(struct connectdata *conn,
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
     break;
c260e0
   default:
c260e0
-    failf(data, "axTLS only supports TLSv1");
c260e0
+    failf(data, "axTLS only supports TLS 1.0 and 1.1, "
c260e0
+          "and it cannot be specified which one to use");
c260e0
     return CURLE_SSL_CONNECT_ERROR;
c260e0
   }
c260e0
 
c260e0
diff --git a/lib/curl_darwinssl.c b/lib/curl_darwinssl.c
c260e0
index 827c876..69eff8a 100644
c260e0
--- a/lib/curl_darwinssl.c
c260e0
+++ b/lib/curl_darwinssl.c
c260e0
@@ -719,6 +719,18 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
c260e0
         (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol1);
c260e0
         (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12);
c260e0
         break;
c260e0
+      case CURL_SSLVERSION_TLSv1_0:
c260e0
+        (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol1);
c260e0
+        (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol1);
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_1:
c260e0
+        (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol11);
c260e0
+        (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol11);
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_2:
c260e0
+        (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol12);
c260e0
+        (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12);
c260e0
+        break;
c260e0
       case CURL_SSLVERSION_SSLv3:
c260e0
         (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3);
c260e0
         (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kSSLProtocol3);
c260e0
@@ -759,6 +771,21 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
c260e0
                                            kTLSProtocol12,
c260e0
                                            true);
c260e0
         break;
c260e0
+      case CURL_SSLVERSION_TLSv1_0:
c260e0
+        (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
+                                           kTLSProtocol1,
c260e0
+                                           true);
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_1:
c260e0
+        (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
+                                           kTLSProtocol11,
c260e0
+                                           true);
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_2:
c260e0
+        (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
+                                           kTLSProtocol12,
c260e0
+                                           true);
c260e0
+        break;
c260e0
       case CURL_SSLVERSION_SSLv3:
c260e0
         (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
                                            kSSLProtocol3,
c260e0
@@ -785,10 +812,17 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
c260e0
                                          true);
c260e0
       break;
c260e0
     case CURL_SSLVERSION_TLSv1:
c260e0
+    case CURL_SSLVERSION_TLSv1_0:
c260e0
       (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
                                          kTLSProtocol1,
c260e0
                                          true);
c260e0
       break;
c260e0
+    case CURL_SSLVERSION_TLSv1_1:
c260e0
+      failf(data, "Your version of the OS does not support TLSv1.1");
c260e0
+      return CURLE_SSL_CONNECT_ERROR;
c260e0
+    case CURL_SSLVERSION_TLSv1_2:
c260e0
+      failf(data, "Your version of the OS does not support TLSv1.2");
c260e0
+      return CURLE_SSL_CONNECT_ERROR;
c260e0
     case CURL_SSLVERSION_SSLv2:
c260e0
       (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
c260e0
                                          kSSLProtocol2,
c260e0
diff --git a/lib/curl_schannel.c b/lib/curl_schannel.c
c260e0
index a615f57..19b7f71 100644
c260e0
--- a/lib/curl_schannel.c
c260e0
+++ b/lib/curl_schannel.c
c260e0
@@ -180,6 +180,15 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
c260e0
                                               SP_PROT_TLS1_1_CLIENT |
c260e0
                                               SP_PROT_TLS1_2_CLIENT;
c260e0
         break;
c260e0
+      case CURL_SSLVERSION_TLSv1_0:
c260e0
+        schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_0_CLIENT;
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_1:
c260e0
+        schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_1_CLIENT;
c260e0
+        break;
c260e0
+      case CURL_SSLVERSION_TLSv1_2:
c260e0
+        schannel_cred.grbitEnabledProtocols = SP_PROT_TLS1_2_CLIENT;
c260e0
+        break;
c260e0
       case CURL_SSLVERSION_SSLv3:
c260e0
         schannel_cred.grbitEnabledProtocols = SP_PROT_SSL3_CLIENT;
c260e0
         break;
c260e0
diff --git a/lib/cyassl.c b/lib/cyassl.c
c260e0
index 7c78464..ff11bdd 100644
c260e0
--- a/lib/cyassl.c
c260e0
+++ b/lib/cyassl.c
c260e0
@@ -5,7 +5,7 @@
c260e0
  *                            | (__| |_| |  _ <| |___
c260e0
  *                             \___|\___/|_| \_\_____|
c260e0
  *
c260e0
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
c260e0
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
c260e0
  *
c260e0
  * This software is licensed as described in the file COPYING, which
c260e0
  * you should have received as part of this distribution. The terms
c260e0
@@ -98,8 +98,19 @@ cyassl_connect_step1(struct connectdata *conn,
c260e0
     req_method = SSLv23_client_method();
c260e0
     break;
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
+    infof(data, "CyaSSL cannot be configured to use TLS 1.0-1.2, "
c260e0
+          "TLS 1.0 is used exclusively\n");
c260e0
     req_method = TLSv1_client_method();
c260e0
     break;
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
+    req_method = TLSv1_client_method();
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+    req_method = TLSv1_1_client_method();
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    req_method = TLSv1_2_client_method();
c260e0
+    break;
c260e0
   case CURL_SSLVERSION_SSLv3:
c260e0
     req_method = SSLv3_client_method();
c260e0
     break;
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index 111982f..ff93a38 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -1266,6 +1266,12 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
   case CURL_SSLVERSION_SSLv3:
c260e0
     ssl3 = PR_TRUE;
c260e0
     break;
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    failf(data, "TLS minor version cannot be set\n");
c260e0
+    curlerr = CURLE_SSL_CONNECT_ERROR;
c260e0
+    goto error;
c260e0
   }
c260e0
 
c260e0
   if(SSL_OptionSet(model, SSL_ENABLE_SSL2, ssl2) != SECSuccess)
c260e0
diff --git a/lib/qssl.c b/lib/qssl.c
c260e0
index 8ef6fec..8b5e499 100644
c260e0
--- a/lib/qssl.c
c260e0
+++ b/lib/qssl.c
c260e0
@@ -206,6 +206,12 @@ static CURLcode Curl_qsossl_handshake(struct connectdata * conn, int sockindex)
c260e0
   case CURL_SSLVERSION_SSLv3:
c260e0
     h->protocol = SSL_VERSION_3;
c260e0
     break;
c260e0
+
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    failf(data, "TLS minor version cannot be set");
c260e0
+    return CURLE_SSL_CONNECT_ERROR;
c260e0
   }
c260e0
 
c260e0
   rc = SSL_Handshake(h, SSL_HANDSHAKE_AS_CLIENT);
c260e0
diff --git a/lib/ssluse.c b/lib/ssluse.c
c260e0
index 4a0dba7..dd99435 100644
c260e0
--- a/lib/ssluse.c
c260e0
+++ b/lib/ssluse.c
c260e0
@@ -1389,19 +1389,12 @@ ossl_connect_step1(struct connectdata *conn,
c260e0
   switch(data->set.ssl.version) {
c260e0
   default:
c260e0
   case CURL_SSLVERSION_DEFAULT:
c260e0
-#ifdef USE_TLS_SRP
c260e0
-    if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
c260e0
-      infof(data, "Set version TLSv1 for SRP authorisation\n");
c260e0
-      req_method = TLSv1_client_method() ;
c260e0
-    }
c260e0
-    else
c260e0
-#endif
c260e0
-    /* we try to figure out version */
c260e0
-    req_method = SSLv23_client_method();
c260e0
-    use_sni(TRUE);
c260e0
-    break;
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
-    req_method = TLSv1_client_method();
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    /* it will be handled later with the context options */
c260e0
+    req_method = SSLv23_client_method();
c260e0
     use_sni(TRUE);
c260e0
     break;
c260e0
   case CURL_SSLVERSION_SSLv2:
c260e0
@@ -1514,9 +1507,39 @@ ossl_connect_step1(struct connectdata *conn,
c260e0
     ctx_options &= ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
c260e0
 #endif
c260e0
 
c260e0
-  /* disable SSLv2 in the default case (i.e. allow SSLv3 and TLSv1) */
c260e0
-  if(data->set.ssl.version == CURL_SSLVERSION_DEFAULT)
c260e0
+  switch(data->set.ssl.version) {
c260e0
+  case CURL_SSLVERSION_DEFAULT:
c260e0
+    ctx_options |= SSL_OP_NO_SSLv2;
c260e0
+#ifdef USE_TLS_SRP
c260e0
+    if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
c260e0
+      infof(data, "Set version TLSv1.x for SRP authorisation\n");
c260e0
+      ctx_options |= SSL_OP_NO_SSLv3;
c260e0
+    }
c260e0
+#endif
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1:
c260e0
+    ctx_options |= SSL_OP_NO_SSLv2;
c260e0
+    ctx_options |= SSL_OP_NO_SSLv3;
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
     ctx_options |= SSL_OP_NO_SSLv2;
c260e0
+    ctx_options |= SSL_OP_NO_SSLv3;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1_1;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1_2;
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+    ctx_options |= SSL_OP_NO_SSLv2;
c260e0
+    ctx_options |= SSL_OP_NO_SSLv3;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1_2;
c260e0
+    break;
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    ctx_options |= SSL_OP_NO_SSLv2;
c260e0
+    ctx_options |= SSL_OP_NO_SSLv3;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1;
c260e0
+    ctx_options |= SSL_OP_NO_TLSv1_1;
c260e0
+    break;
c260e0
+  }
c260e0
 
c260e0
   SSL_CTX_set_options(connssl->ctx, ctx_options);
c260e0
 
c260e0
diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in
c260e0
index 33ca12a..22a5511 100644
c260e0
--- a/packages/OS400/curl.inc.in
c260e0
+++ b/packages/OS400/curl.inc.in
c260e0
@@ -226,6 +226,12 @@
c260e0
      d                 c                   2
c260e0
      d CURL_SSLVERSION_SSLv3...
c260e0
      d                 c                   3
c260e0
+     d CURL_SSLVERSION_TLSv1_0...
c260e0
+     d                 c                   4
c260e0
+     d CURL_SSLVERSION_TLSv1_1...
c260e0
+     d                 c                   5
c260e0
+     d CURL_SSLVERSION_TLSv1_2...
c260e0
+     d                 c                   6
c260e0
       *
c260e0
      d CURL_TLSAUTH_NONE...
c260e0
      d                 c                   0
c260e0
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
c260e0
index 297b986..98d53a7 100644
c260e0
--- a/src/tool_getparam.c
c260e0
+++ b/src/tool_getparam.c
c260e0
@@ -175,6 +175,9 @@ static const struct LongShort aliases[]= {
c260e0
   {"$J", "metalink",                 FALSE},
c260e0
   {"0",  "http1.0",                  FALSE},
c260e0
   {"1",  "tlsv1",                    FALSE},
c260e0
+  {"10",  "tlsv1.0",                 FALSE},
c260e0
+  {"11",  "tlsv1.1",                 FALSE},
c260e0
+  {"12",  "tlsv1.2",                 FALSE},
c260e0
   {"2",  "sslv2",                    FALSE},
c260e0
   {"3",  "sslv3",                    FALSE},
c260e0
   {"4",  "ipv4",                     FALSE},
c260e0
@@ -873,9 +876,25 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
c260e0
       /* HTTP version 1.0 */
c260e0
       config->httpversion = CURL_HTTP_VERSION_1_0;
c260e0
       break;
c260e0
-    case '1':
c260e0
-      /* TLS version 1 */
c260e0
-      config->ssl_version = CURL_SSLVERSION_TLSv1;
c260e0
+    case '1': /* --tlsv1* options */
c260e0
+      switch(subletter) {
c260e0
+      case '\0':
c260e0
+        /* TLS version 1.x */
c260e0
+        config->ssl_version = CURL_SSLVERSION_TLSv1;
c260e0
+        break;
c260e0
+      case '0':
c260e0
+        /* TLS version 1.0 */
c260e0
+        config->ssl_version = CURL_SSLVERSION_TLSv1_0;
c260e0
+        break;
c260e0
+      case '1':
c260e0
+        /* TLS version 1.1 */
c260e0
+        config->ssl_version = CURL_SSLVERSION_TLSv1_1;
c260e0
+        break;
c260e0
+      case '2':
c260e0
+        /* TLS version 1.2 */
c260e0
+        config->ssl_version = CURL_SSLVERSION_TLSv1_2;
c260e0
+        break;
c260e0
+      }
c260e0
       break;
c260e0
     case '2':
c260e0
       /* SSL version 2 */
c260e0
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
c260e0
index 4014177..9860117 100644
c260e0
--- a/src/tool_setopt.c
c260e0
+++ b/src/tool_setopt.c
c260e0
@@ -78,6 +78,9 @@ const NameValue setopt_nv_CURL_SSLVERSION[] = {
c260e0
   NV(CURL_SSLVERSION_TLSv1),
c260e0
   NV(CURL_SSLVERSION_SSLv2),
c260e0
   NV(CURL_SSLVERSION_SSLv3),
c260e0
+  NV(CURL_SSLVERSION_TLSv1_0),
c260e0
+  NV(CURL_SSLVERSION_TLSv1_1),
c260e0
+  NV(CURL_SSLVERSION_TLSv1_2),
c260e0
   NVEND,
c260e0
 };
c260e0
 
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 350765306d7e2946fc8295fa2bfc2fe0c14651fc Mon Sep 17 00:00:00 2001
c260e0
From: Daniel Stenberg <daniel@haxx.se>
c260e0
Date: Tue, 15 Oct 2013 20:31:04 +0200
c260e0
Subject: [PATCH 2/9] curl: document the new --tlsv1.[012] options
c260e0
c260e0
[upstream commit 076726f1412205622414abd908723c4b33ca12cb]
c260e0
---
c260e0
 docs/curl.1 |   20 ++++++++++++++++----
c260e0
 1 files changed, 16 insertions(+), 4 deletions(-)
c260e0
c260e0
diff --git a/docs/curl.1 b/docs/curl.1
c260e0
index b350865..53b378c 100644
c260e0
--- a/docs/curl.1
c260e0
+++ b/docs/curl.1
c260e0
@@ -1419,14 +1419,26 @@ Set TLS authentication type. Currently, the only supported option is "SRP",
c260e0
 for TLS-SRP (RFC 5054). If \fI--tlsuser\fP and \fI--tlspassword\fP are
c260e0
 specified but \fI--tlsauthtype\fP is not, then this option defaults to "SRP".
c260e0
 (Added in 7.21.4)
c260e0
-.IP "--tlsuser <user>"
c260e0
-Set username for use with the TLS authentication method specified with
c260e0
-\fI--tlsauthtype\fP. Requires that \fI--tlspassword\fP also be set.  (Added in
c260e0
-7.21.4)
c260e0
 .IP "--tlspassword <password>"
c260e0
 Set password for use with the TLS authentication method specified with
c260e0
 \fI--tlsauthtype\fP. Requires that \fI--tlsuser\fP also be set.  (Added in
c260e0
 7.21.4)
c260e0
+.IP "--tlsuser <user>"
c260e0
+Set username for use with the TLS authentication method specified with
c260e0
+\fI--tlsauthtype\fP. Requires that \fI--tlspassword\fP also be set.  (Added in
c260e0
+7.21.4)
c260e0
+.IP "--tlsv1.0"
c260e0
+(SSL)
c260e0
+Forces curl to use TLS version 1.0 when negotiating with a remote TLS server.
c260e0
+(Added in 7.34.0)
c260e0
+.IP "--tlsv1.1"
c260e0
+(SSL)
c260e0
+Forces curl to use TLS version 1.1 when negotiating with a remote TLS server.
c260e0
+(Added in 7.34.0)
c260e0
+.IP "--tlsv1.2"
c260e0
+(SSL)
c260e0
+Forces curl to use TLS version 1.2 when negotiating with a remote TLS server.
c260e0
+(Added in 7.34.0)
c260e0
 .IP "--tr-encoding"
c260e0
 (HTTP) Request a compressed Transfer-Encoding response using one of the
c260e0
 algorithms curl supports, and uncompress the data while receiving it.
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From ba2b4e87b396faab9ccb5a3ca9aca935a7a78a1b Mon Sep 17 00:00:00 2001
c260e0
From: Steve Holme <steve_holme@hotmail.com>
c260e0
Date: Wed, 16 Oct 2013 20:06:23 +0100
c260e0
Subject: [PATCH 3/9] SSL: Corrected version number for new symbols from commit ad34a2d5c87c7f
c260e0
c260e0
[upstream commit 2c84ffe1549ea7d5029ba7863f53013562e6758d]
c260e0
---
c260e0
 docs/libcurl/symbols-in-versions |    6 +++---
c260e0
 1 files changed, 3 insertions(+), 3 deletions(-)
c260e0
c260e0
diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
c260e0
index 57fa6eb..b275900 100644
c260e0
--- a/docs/libcurl/symbols-in-versions
c260e0
+++ b/docs/libcurl/symbols-in-versions
c260e0
@@ -678,9 +678,9 @@ CURL_SSLVERSION_DEFAULT         7.9.2
c260e0
 CURL_SSLVERSION_SSLv2           7.9.2
c260e0
 CURL_SSLVERSION_SSLv3           7.9.2
c260e0
 CURL_SSLVERSION_TLSv1           7.9.2
c260e0
-CURL_SSLVERSION_TLSv1_0         7.33.0
c260e0
-CURL_SSLVERSION_TLSv1_1         7.33.0
c260e0
-CURL_SSLVERSION_TLSv1_2         7.33.0
c260e0
+CURL_SSLVERSION_TLSv1_0         7.34.0
c260e0
+CURL_SSLVERSION_TLSv1_1         7.34.0
c260e0
+CURL_SSLVERSION_TLSv1_2         7.34.0
c260e0
 CURL_TIMECOND_IFMODSINCE        7.9.7
c260e0
 CURL_TIMECOND_IFUNMODSINCE      7.9.7
c260e0
 CURL_TIMECOND_LASTMOD           7.9.7
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 5f908139b4e56c969bf6ef06c115a0a12353c827 Mon Sep 17 00:00:00 2001
c260e0
From: Steve Holme <steve_holme@hotmail.com>
c260e0
Date: Wed, 16 Oct 2013 20:18:15 +0100
c260e0
Subject: [PATCH 4/9] DOCS: Added libcurl version number to CURLOPT_SSLVERSION
c260e0
c260e0
[upstream commit 75b9b26465d5f01b52564293c2d553649f801f70]
c260e0
---
c260e0
 docs/libcurl/curl_easy_setopt.3 |    8 +++++---
c260e0
 1 files changed, 5 insertions(+), 3 deletions(-)
c260e0
c260e0
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
c260e0
index 92db8f4..d73b664 100644
c260e0
--- a/docs/libcurl/curl_easy_setopt.3
c260e0
+++ b/docs/libcurl/curl_easy_setopt.3
c260e0
@@ -2212,6 +2212,8 @@ Even though this option doesn't need any parameter, in some configurations
c260e0
 arguments. Therefore, it's recommended to pass 1 as parameter to this option.
c260e0
 .IP CURLOPT_SSLVERSION
c260e0
 Pass a long as parameter to control what version of SSL/TLS to attempt to use.
c260e0
+(Added in 7.9.2)
c260e0
+
c260e0
 The available options are:
c260e0
 .RS
c260e0
 .IP CURL_SSLVERSION_DEFAULT
c260e0
@@ -2225,11 +2227,11 @@ Force SSLv2
c260e0
 .IP CURL_SSLVERSION_SSLv3
c260e0
 Force SSLv3
c260e0
 .IP CURL_SSLVERSION_TLSv1_0
c260e0
-Force TLSv1.0
c260e0
+Force TLSv1.0 (Added in 7.34.0)
c260e0
 .IP CURL_SSLVERSION_TLSv1_1
c260e0
-Force TLSv1.1
c260e0
+Force TLSv1.1 (Added in 7.34.0)
c260e0
 .IP CURL_SSLVERSION_TLSv1_2
c260e0
-Force TLSv1.2
c260e0
+Force TLSv1.2 (Added in 7.34.0)
c260e0
 .RE
c260e0
 .IP CURLOPT_SSL_VERIFYPEER
c260e0
 Pass a long as parameter. By default, curl assumes a value of 1.
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 7940044fc233f626b912b5f51a7a0111a4c145d3 Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 25 Nov 2013 16:03:52 +0100
c260e0
Subject: [PATCH 5/9] nss: use a better API for controlling SSL version
c260e0
c260e0
This change introduces a dependency on NSS 3.14+.
c260e0
c260e0
[upstream commit 30e7e7552ba4397896ecac82ea04f38d52c4cc8f]
c260e0
---
c260e0
 configure      |   20 ++++++++++----------
c260e0
 configure.ac   |    4 ++--
c260e0
 docs/INTERNALS |    2 +-
c260e0
 lib/nss.c      |   40 +++++++++++++++++++---------------------
c260e0
 4 files changed, 32 insertions(+), 34 deletions(-)
c260e0
c260e0
diff --git a/configure b/configure
c260e0
index 2496b3c..ebde78a 100755
c260e0
--- a/configure
c260e0
+++ b/configure
c260e0
@@ -23641,9 +23641,9 @@ $as_echo "found" >&6; }
c260e0
          CPPFLAGS="$CPPFLAGS $addcflags"
c260e0
       fi
c260e0
 
c260e0
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PK11_CreateGenericObject in -lnss3" >&5
c260e0
-$as_echo_n "checking for PK11_CreateGenericObject in -lnss3... " >&6; }
c260e0
-if ${ac_cv_lib_nss3_PK11_CreateGenericObject+:} false; then :
c260e0
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_VersionRangeSet in -lnss3" >&5
c260e0
+$as_echo_n "checking for SSL_VersionRangeSet in -lnss3... " >&6; }
c260e0
+if ${ac_cv_lib_nss3_SSL_VersionRangeSet+:} false; then :
c260e0
   $as_echo_n "(cached) " >&6
c260e0
 else
c260e0
   ac_check_lib_save_LIBS=$LIBS
c260e0
@@ -23655,26 +23655,26 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
c260e0
 #ifdef __cplusplus
c260e0
 extern "C"
c260e0
 #endif
c260e0
-char PK11_CreateGenericObject ();
c260e0
+char SSL_VersionRangeSet ();
c260e0
 int main (void)
c260e0
 {
c260e0
-return PK11_CreateGenericObject ();
c260e0
+return SSL_VersionRangeSet ();
c260e0
  ;
c260e0
  return 0;
c260e0
 }
c260e0
 _ACEOF
c260e0
 if ac_fn_c_try_link "$LINENO"; then :
c260e0
-  ac_cv_lib_nss3_PK11_CreateGenericObject=yes
c260e0
+  ac_cv_lib_nss3_SSL_VersionRangeSet=yes
c260e0
 else
c260e0
-  ac_cv_lib_nss3_PK11_CreateGenericObject=no
c260e0
+  ac_cv_lib_nss3_SSL_VersionRangeSet=no
c260e0
 fi
c260e0
 rm -f core conftest.err conftest.$ac_objext \
c260e0
     conftest$ac_exeext conftest.$ac_ext
c260e0
 LIBS=$ac_check_lib_save_LIBS
c260e0
 fi
c260e0
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nss3_PK11_CreateGenericObject" >&5
c260e0
-$as_echo "$ac_cv_lib_nss3_PK11_CreateGenericObject" >&6; }
c260e0
-if test "x$ac_cv_lib_nss3_PK11_CreateGenericObject" = xyes; then :
c260e0
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nss3_SSL_VersionRangeSet" >&5
c260e0
+$as_echo "$ac_cv_lib_nss3_SSL_VersionRangeSet" >&6; }
c260e0
+if test "x$ac_cv_lib_nss3_SSL_VersionRangeSet" = xyes; then :
c260e0
 
c260e0
 
c260e0
 $as_echo "#define USE_NSS 1" >>confdefs.h
c260e0
diff --git a/configure.ac b/configure.ac
c260e0
index 5970188..c81c879 100644
c260e0
--- a/configure.ac
c260e0
+++ b/configure.ac
c260e0
@@ -2194,8 +2194,8 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
c260e0
          CPPFLAGS="$CPPFLAGS $addcflags"
c260e0
       fi
c260e0
 
c260e0
-      dnl The function PK11_CreateGenericObject is needed to load libnsspem.so
c260e0
-      AC_CHECK_LIB(nss3, PK11_CreateGenericObject,
c260e0
+      dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
c260e0
+      AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
c260e0
        [
c260e0
        AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
c260e0
        AC_SUBST(USE_NSS, [1])
c260e0
diff --git a/docs/INTERNALS b/docs/INTERNALS
c260e0
index 03839c3..581b22d 100644
c260e0
--- a/docs/INTERNALS
c260e0
+++ b/docs/INTERNALS
c260e0
@@ -43,7 +43,7 @@ Portability
c260e0
  openldap     2.0
c260e0
  MIT krb5 lib 1.2.4
c260e0
  qsossl       V5R2M0
c260e0
- NSS          3.12.x
c260e0
+ NSS          3.14.x
c260e0
  axTLS        1.2.7
c260e0
  Heimdal      ?
c260e0
 
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index ff93a38..14a0b0c 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -1175,9 +1175,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
 {
c260e0
   PRErrorCode err = 0;
c260e0
   PRFileDesc *model = NULL;
c260e0
-  PRBool ssl2 = PR_FALSE;
c260e0
-  PRBool ssl3 = PR_FALSE;
c260e0
-  PRBool tlsv1 = PR_FALSE;
c260e0
+  SSLVersionRange sslver;
c260e0
   PRBool ssl_no_cache;
c260e0
   PRBool ssl_cbc_random_iv;
c260e0
   struct SessionHandle *data = conn->data;
c260e0
@@ -1251,20 +1249,25 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
   switch (data->set.ssl.version) {
c260e0
   default:
c260e0
   case CURL_SSLVERSION_DEFAULT:
c260e0
-    ssl3 = PR_TRUE;
c260e0
-    if(data->state.ssl_connect_retry)
c260e0
+    sslver.min = SSL_LIBRARY_VERSION_3_0;
c260e0
+    if(data->state.ssl_connect_retry) {
c260e0
       infof(data, "TLS disabled due to previous handshake failure\n");
c260e0
+      sslver.max = SSL_LIBRARY_VERSION_3_0;
c260e0
+    }
c260e0
     else
c260e0
-      tlsv1 = PR_TRUE;
c260e0
+      sslver.max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
     break;
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
-    tlsv1 = PR_TRUE;
c260e0
+    sslver.min = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    sslver.max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
     break;
c260e0
   case CURL_SSLVERSION_SSLv2:
c260e0
-    ssl2 = PR_TRUE;
c260e0
+    sslver.min = SSL_LIBRARY_VERSION_2;
c260e0
+    sslver.max = SSL_LIBRARY_VERSION_2;
c260e0
     break;
c260e0
   case CURL_SSLVERSION_SSLv3:
c260e0
-    ssl3 = PR_TRUE;
c260e0
+    sslver.min = SSL_LIBRARY_VERSION_3_0;
c260e0
+    sslver.max = SSL_LIBRARY_VERSION_3_0;
c260e0
     break;
c260e0
   case CURL_SSLVERSION_TLSv1_0:
c260e0
   case CURL_SSLVERSION_TLSv1_1:
c260e0
@@ -1274,14 +1277,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
     goto error;
c260e0
   }
c260e0
 
c260e0
-  if(SSL_OptionSet(model, SSL_ENABLE_SSL2, ssl2) != SECSuccess)
c260e0
-    goto error;
c260e0
-  if(SSL_OptionSet(model, SSL_ENABLE_SSL3, ssl3) != SECSuccess)
c260e0
-    goto error;
c260e0
-  if(SSL_OptionSet(model, SSL_ENABLE_TLS, tlsv1) != SECSuccess)
c260e0
-    goto error;
c260e0
-
c260e0
-  if(SSL_OptionSet(model, SSL_V2_COMPATIBLE_HELLO, ssl2) != SECSuccess)
c260e0
+  if(SSL_VersionRangeSet(model, &sslver) != SECSuccess)
c260e0
     goto error;
c260e0
 
c260e0
   ssl_cbc_random_iv = !data->set.ssl_enable_beast;
c260e0
@@ -1467,11 +1463,13 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
   if(model)
c260e0
     PR_Close(model);
c260e0
 
c260e0
-    /* cleanup on connection failure */
c260e0
-    Curl_llist_destroy(connssl->obj_list, NULL);
c260e0
-    connssl->obj_list = NULL;
c260e0
+  /* cleanup on connection failure */
c260e0
+  Curl_llist_destroy(connssl->obj_list, NULL);
c260e0
+  connssl->obj_list = NULL;
c260e0
 
c260e0
-  if(ssl3 && tlsv1 && isTLSIntoleranceError(err)) {
c260e0
+  if((sslver.min == SSL_LIBRARY_VERSION_3_0)
c260e0
+      && (sslver.max == SSL_LIBRARY_VERSION_TLS_1_0)
c260e0
+      && isTLSIntoleranceError(err)) {
c260e0
     /* schedule reconnect through Curl_retry_request() */
c260e0
     data->state.ssl_connect_retry = TRUE;
c260e0
     infof(data, "Error in TLS handshake, trying SSLv3...\n");
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 08398e7a8a8ba4e6fef1557392e3c0104cc3550f Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 25 Nov 2013 16:14:55 +0100
c260e0
Subject: [PATCH 6/9] nss: put SSL version selection into separate fnc
c260e0
c260e0
[upstream commit 4fb8241add5b68e95fbf44d3c2bf470201a9915d]
c260e0
---
c260e0
 lib/nss.c |   72 +++++++++++++++++++++++++++++++++++-------------------------
c260e0
 1 files changed, 42 insertions(+), 30 deletions(-)
c260e0
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index 14a0b0c..2e2240b 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -1171,6 +1171,46 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn,
c260e0
   return CURLE_OK;
c260e0
 }
c260e0
 
c260e0
+static CURLcode nss_init_sslver(SSLVersionRange *sslver,
c260e0
+                                struct SessionHandle *data)
c260e0
+{
c260e0
+  switch (data->set.ssl.version) {
c260e0
+  default:
c260e0
+  case CURL_SSLVERSION_DEFAULT:
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_3_0;
c260e0
+    if(data->state.ssl_connect_retry) {
c260e0
+      infof(data, "TLS disabled due to previous handshake failure\n");
c260e0
+      sslver->max = SSL_LIBRARY_VERSION_3_0;
c260e0
+    }
c260e0
+    else
c260e0
+      sslver->max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    return CURLE_OK;
c260e0
+
c260e0
+  case CURL_SSLVERSION_TLSv1:
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    return CURLE_OK;
c260e0
+
c260e0
+  case CURL_SSLVERSION_SSLv2:
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_2;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_2;
c260e0
+    return CURLE_OK;
c260e0
+
c260e0
+  case CURL_SSLVERSION_SSLv3:
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_3_0;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_3_0;
c260e0
+    return CURLE_OK;
c260e0
+
c260e0
+  case CURL_SSLVERSION_TLSv1_0:
c260e0
+  case CURL_SSLVERSION_TLSv1_1:
c260e0
+  case CURL_SSLVERSION_TLSv1_2:
c260e0
+    break;
c260e0
+  }
c260e0
+
c260e0
+  failf(data, "TLS minor version cannot be set");
c260e0
+  return CURLE_SSL_CONNECT_ERROR;
c260e0
+}
c260e0
+
c260e0
 CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
 {
c260e0
   PRErrorCode err = 0;
c260e0
@@ -1246,37 +1286,9 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
   if(SSL_OptionSet(model, SSL_NO_CACHE, ssl_no_cache) != SECSuccess)
c260e0
     goto error;
c260e0
 
c260e0
-  switch (data->set.ssl.version) {
c260e0
-  default:
c260e0
-  case CURL_SSLVERSION_DEFAULT:
c260e0
-    sslver.min = SSL_LIBRARY_VERSION_3_0;
c260e0
-    if(data->state.ssl_connect_retry) {
c260e0
-      infof(data, "TLS disabled due to previous handshake failure\n");
c260e0
-      sslver.max = SSL_LIBRARY_VERSION_3_0;
c260e0
-    }
c260e0
-    else
c260e0
-      sslver.max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
-    break;
c260e0
-  case CURL_SSLVERSION_TLSv1:
c260e0
-    sslver.min = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
-    sslver.max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
-    break;
c260e0
-  case CURL_SSLVERSION_SSLv2:
c260e0
-    sslver.min = SSL_LIBRARY_VERSION_2;
c260e0
-    sslver.max = SSL_LIBRARY_VERSION_2;
c260e0
-    break;
c260e0
-  case CURL_SSLVERSION_SSLv3:
c260e0
-    sslver.min = SSL_LIBRARY_VERSION_3_0;
c260e0
-    sslver.max = SSL_LIBRARY_VERSION_3_0;
c260e0
-    break;
c260e0
-  case CURL_SSLVERSION_TLSv1_0:
c260e0
-  case CURL_SSLVERSION_TLSv1_1:
c260e0
-  case CURL_SSLVERSION_TLSv1_2:
c260e0
-    failf(data, "TLS minor version cannot be set\n");
c260e0
-    curlerr = CURLE_SSL_CONNECT_ERROR;
c260e0
+  /* enable/disable the requested SSL version(s) */
c260e0
+  if(nss_init_sslver(&sslver, data) != CURLE_OK)
c260e0
     goto error;
c260e0
-  }
c260e0
-
c260e0
   if(SSL_VersionRangeSet(model, &sslver) != SECSuccess)
c260e0
     goto error;
c260e0
 
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 91a3d58fc48f0d08ab81f1e013b2d58a7ccd7146 Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 25 Nov 2013 16:25:15 +0100
c260e0
Subject: [PATCH 7/9] nss: allow to use TLS > 1.0 if built against recent NSS
c260e0
c260e0
Bug: http://curl.haxx.se/mail/lib-2013-11/0162.html
c260e0
c260e0
[upstream commit 7fc9325a52a6dad1f8b859a3269472ffc125edd0]
c260e0
---
c260e0
 lib/nss.c |   22 ++++++++++++++++++++++
c260e0
 1 files changed, 22 insertions(+), 0 deletions(-)
c260e0
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index 2e2240b..5cd33d8 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -1188,7 +1188,13 @@ static CURLcode nss_init_sslver(SSLVersionRange *sslver,
c260e0
 
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
     sslver->min = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+#ifdef SSL_LIBRARY_VERSION_TLS_1_2
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_2;
c260e0
+#elif defined SSL_LIBRARY_VERSION_TLS_1_1
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_1;
c260e0
+#else
c260e0
     sslver->max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+#endif
c260e0
     return CURLE_OK;
c260e0
 
c260e0
   case CURL_SSLVERSION_SSLv2:
c260e0
@@ -1202,8 +1208,24 @@ static CURLcode nss_init_sslver(SSLVersionRange *sslver,
c260e0
     return CURLE_OK;
c260e0
 
c260e0
   case CURL_SSLVERSION_TLSv1_0:
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
+    return CURLE_OK;
c260e0
+
c260e0
   case CURL_SSLVERSION_TLSv1_1:
c260e0
+#ifdef SSL_LIBRARY_VERSION_TLS_1_1
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_TLS_1_1;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_1;
c260e0
+    return CURLE_OK;
c260e0
+#endif
c260e0
+    break;
c260e0
+
c260e0
   case CURL_SSLVERSION_TLSv1_2:
c260e0
+#ifdef SSL_LIBRARY_VERSION_TLS_1_2
c260e0
+    sslver->min = SSL_LIBRARY_VERSION_TLS_1_2;
c260e0
+    sslver->max = SSL_LIBRARY_VERSION_TLS_1_2;
c260e0
+    return CURLE_OK;
c260e0
+#endif
c260e0
     break;
c260e0
   }
c260e0
 
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From 404492a5a815b83fab58ce60434c01c270b6bc73 Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 2 Dec 2013 14:25:07 +0100
c260e0
Subject: [PATCH 8/9] nss: unconditionally require NSS_InitContext()
c260e0
c260e0
... since we depend on NSS 3.14+ because of SSL_VersionRangeSet() anyway
c260e0
c260e0
[upstream commit 865666afca926faa1c721020fc54364540caf734]
c260e0
---
c260e0
 configure    |   12 ------------
c260e0
 configure.ac |    8 --------
c260e0
 lib/nss.c    |   26 --------------------------
c260e0
 3 files changed, 0 insertions(+), 46 deletions(-)
c260e0
c260e0
diff --git a/configure b/configure
c260e0
index ebde78a..8741e21 100755
c260e0
--- a/configure
c260e0
+++ b/configure
c260e0
@@ -23697,18 +23697,6 @@ fi
c260e0
         { $as_echo "$as_me:${as_lineno-$LINENO}: detected NSS version $version" >&5
c260e0
 $as_echo "$as_me: detected NSS version $version" >&6;}
c260e0
 
c260e0
-                        ac_fn_c_check_func "$LINENO" "NSS_InitContext" "ac_cv_func_NSS_InitContext"
c260e0
-if test "x$ac_cv_func_NSS_InitContext" = xyes; then :
c260e0
-
c260e0
-
c260e0
-$as_echo "#define HAVE_NSS_INITCONTEXT 1" >>confdefs.h
c260e0
-
c260e0
-          HAVE_NSS_INITCONTEXT=1
c260e0
-
c260e0
-
c260e0
-fi
c260e0
-
c260e0
-
c260e0
                                         if test "x$cross_compiling" != "xyes"; then
c260e0
           LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
c260e0
           export LD_LIBRARY_PATH
c260e0
diff --git a/configure.ac b/configure.ac
c260e0
index c81c879..70ef0b7 100644
c260e0
--- a/configure.ac
c260e0
+++ b/configure.ac
c260e0
@@ -2211,14 +2211,6 @@ if test "$curl_ssl_msg" = "$init_ssl_msg"; then
c260e0
       if test "x$USE_NSS" = "xyes"; then
c260e0
         AC_MSG_NOTICE([detected NSS version $version])
c260e0
 
c260e0
-        dnl NSS_InitContext() was introduced in NSS 3.12.5 and helps to prevent
c260e0
-        dnl collisions on NSS initialization/shutdown with other libraries
c260e0
-        AC_CHECK_FUNC(NSS_InitContext,
c260e0
-        [
c260e0
-          AC_DEFINE(HAVE_NSS_INITCONTEXT, 1, [if you have the NSS_InitContext function])
c260e0
-          AC_SUBST(HAVE_NSS_INITCONTEXT, [1])
c260e0
-        ])
c260e0
-
c260e0
         dnl when shared libs were found in a path that the run-time
c260e0
         dnl linker doesn't search through, we need to add it to
c260e0
         dnl LD_LIBRARY_PATH to prevent further configure tests to fail
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index 5cd33d8..7b49c20 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -76,9 +76,7 @@ PRFileDesc *PR_ImportTCPSocket(PRInt32 osfd);
c260e0
 
c260e0
 PRLock * nss_initlock = NULL;
c260e0
 PRLock * nss_crllock = NULL;
c260e0
-#ifdef HAVE_NSS_INITCONTEXT
c260e0
 NSSInitContext * nss_context = NULL;
c260e0
-#endif
c260e0
 
c260e0
 volatile int initialized = 0;
c260e0
 
c260e0
@@ -853,7 +851,6 @@ isTLSIntoleranceError(PRInt32 err)
c260e0
 
c260e0
 static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir)
c260e0
 {
c260e0
-#ifdef HAVE_NSS_INITCONTEXT
c260e0
   NSSInitParameters initparams;
c260e0
 
c260e0
   if(nss_context != NULL)
c260e0
@@ -861,12 +858,6 @@ static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir)
c260e0
 
c260e0
   memset((void *) &initparams, '\0', sizeof(initparams));
c260e0
   initparams.length = sizeof(initparams);
c260e0
-#else /* HAVE_NSS_INITCONTEXT */
c260e0
-  SECStatus rv;
c260e0
-
c260e0
-  if(NSS_IsInitialized())
c260e0
-    return CURLE_OK;
c260e0
-#endif
c260e0
 
c260e0
   if(cert_dir) {
c260e0
     const bool use_sql = NSS_VersionCheck("3.12.0");
c260e0
@@ -875,35 +866,22 @@ static CURLcode nss_init_core(struct SessionHandle *data, const char *cert_dir)
c260e0
       return CURLE_OUT_OF_MEMORY;
c260e0
 
c260e0
     infof(data, "Initializing NSS with certpath: %s\n", certpath);
c260e0
-#ifdef HAVE_NSS_INITCONTEXT
c260e0
     nss_context = NSS_InitContext(certpath, "", "", "", &initparams,
c260e0
             NSS_INIT_READONLY | NSS_INIT_PK11RELOAD);
c260e0
     free(certpath);
c260e0
 
c260e0
     if(nss_context != NULL)
c260e0
       return CURLE_OK;
c260e0
-#else /* HAVE_NSS_INITCONTEXT */
c260e0
-    rv = NSS_Initialize(certpath, "", "", "", NSS_INIT_READONLY);
c260e0
-    free(certpath);
c260e0
-
c260e0
-    if(rv == SECSuccess)
c260e0
-      return CURLE_OK;
c260e0
-#endif
c260e0
 
c260e0
     infof(data, "Unable to initialize NSS database\n");
c260e0
   }
c260e0
 
c260e0
   infof(data, "Initializing NSS with certpath: none\n");
c260e0
-#ifdef HAVE_NSS_INITCONTEXT
c260e0
   nss_context = NSS_InitContext("", "", "", "", &initparams, NSS_INIT_READONLY
c260e0
          | NSS_INIT_NOCERTDB   | NSS_INIT_NOMODDB       | NSS_INIT_FORCEOPEN
c260e0
          | NSS_INIT_NOROOTINIT | NSS_INIT_OPTIMIZESPACE | NSS_INIT_PK11RELOAD);
c260e0
   if(nss_context != NULL)
c260e0
     return CURLE_OK;
c260e0
-#else /* HAVE_NSS_INITCONTEXT */
c260e0
-  if(NSS_NoDB_Init(NULL) == SECSuccess)
c260e0
-    return CURLE_OK;
c260e0
-#endif
c260e0
 
c260e0
   infof(data, "Unable to initialize NSS\n");
c260e0
   return CURLE_SSL_CACERT_BADFILE;
c260e0
@@ -999,12 +977,8 @@ void Curl_nss_cleanup(void)
c260e0
       SECMOD_DestroyModule(mod);
c260e0
       mod = NULL;
c260e0
     }
c260e0
-#ifdef HAVE_NSS_INITCONTEXT
c260e0
     NSS_ShutdownContext(nss_context);
c260e0
     nss_context = NULL;
c260e0
-#else /* HAVE_NSS_INITCONTEXT */
c260e0
-    NSS_Shutdown();
c260e0
-#endif
c260e0
   }
c260e0
   PR_Unlock(nss_initlock);
c260e0
 
c260e0
-- 
c260e0
1.7.1
c260e0
c260e0
c260e0
From a643c75662b6909a5be1bed8273ed1273ab2b3f4 Mon Sep 17 00:00:00 2001
c260e0
From: Kamil Dudka <kdudka@redhat.com>
c260e0
Date: Mon, 2 Dec 2013 16:09:12 +0100
c260e0
Subject: [PATCH 9/9] nss: make sure that 'sslver' is always initialized
c260e0
c260e0
[upstream commit e221b55f67a2e12717e911f25d1bb6c85fcebfab]
c260e0
---
c260e0
 lib/nss.c |    9 +++++----
c260e0
 1 files changed, 5 insertions(+), 4 deletions(-)
c260e0
c260e0
diff --git a/lib/nss.c b/lib/nss.c
c260e0
index 7b49c20..abc8a91 100644
c260e0
--- a/lib/nss.c
c260e0
+++ b/lib/nss.c
c260e0
@@ -1151,13 +1151,10 @@ static CURLcode nss_init_sslver(SSLVersionRange *sslver,
c260e0
   switch (data->set.ssl.version) {
c260e0
   default:
c260e0
   case CURL_SSLVERSION_DEFAULT:
c260e0
-    sslver->min = SSL_LIBRARY_VERSION_3_0;
c260e0
     if(data->state.ssl_connect_retry) {
c260e0
       infof(data, "TLS disabled due to previous handshake failure\n");
c260e0
       sslver->max = SSL_LIBRARY_VERSION_3_0;
c260e0
     }
c260e0
-    else
c260e0
-      sslver->max = SSL_LIBRARY_VERSION_TLS_1_0;
c260e0
     return CURLE_OK;
c260e0
 
c260e0
   case CURL_SSLVERSION_TLSv1:
c260e0
@@ -1211,7 +1208,6 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
 {
c260e0
   PRErrorCode err = 0;
c260e0
   PRFileDesc *model = NULL;
c260e0
-  SSLVersionRange sslver;
c260e0
   PRBool ssl_no_cache;
c260e0
   PRBool ssl_cbc_random_iv;
c260e0
   struct SessionHandle *data = conn->data;
c260e0
@@ -1223,6 +1219,11 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
c260e0
   long time_left;
c260e0
   PRUint32 timeout;
c260e0
 
c260e0
+  SSLVersionRange sslver = {
c260e0
+    SSL_LIBRARY_VERSION_3_0,      /* min */
c260e0
+    SSL_LIBRARY_VERSION_TLS_1_0   /* max */
c260e0
+  };
c260e0
+
c260e0
   if(connssl->state == ssl_connection_complete)
c260e0
     return CURLE_OK;
c260e0
 
c260e0
-- 
c260e0
1.7.1
c260e0