Blame SOURCES/wget-1.14-add-openssl-tlsv11-tlsv12-support.patch

966d16
diff --git a/doc/wget.texi b/doc/wget.texi
966d16
index 118fce9..3bd8dd7 100644
966d16
--- a/doc/wget.texi
966d16
+++ b/doc/wget.texi
966d16
@@ -1555,16 +1555,17 @@ without SSL support, none of these options are available.
966d16
 @cindex SSL protocol, choose
966d16
 @item --secure-protocol=@var{protocol}
966d16
 Choose the secure protocol to be used.  Legal values are @samp{auto},
966d16
-@samp{SSLv2}, @samp{SSLv3}, and @samp{TLSv1}.  If @samp{auto} is used,
966d16
-the SSL library is given the liberty of choosing the appropriate
966d16
-protocol automatically, which is achieved by sending an SSLv2 greeting
966d16
-and announcing support for SSLv3 and TLSv1.  This is the default.
966d16
-
966d16
-Specifying @samp{SSLv2}, @samp{SSLv3}, or @samp{TLSv1} forces the use
966d16
-of the corresponding protocol.  This is useful when talking to old and
966d16
-buggy SSL server implementations that make it hard for OpenSSL to
966d16
-choose the correct protocol version.  Fortunately, such servers are
966d16
-quite rare.
966d16
+@samp{SSLv2}, @samp{SSLv3}, @samp{TLSv1}, @samp{TLSv1_1} and
966d16
+@samp{TLSv1_2}.  If @samp{auto} is used, the SSL library is given the
966d16
+liberty of choosing the appropriate protocol automatically, which is
966d16
+achieved by sending a SSLv2 greeting and announcing support for SSLv3
966d16
+and TLSv1.  This is the default.
966d16
+
966d16
+Specifying @samp{SSLv2}, @samp{SSLv3}, @samp{TLSv1}, @samp{TLSv1_1} or
966d16
+@samp{TLSv1_2} forces the use of the corresponding protocol.  This is
966d16
+useful when talking to old and buggy SSL server implementations that
966d16
+make it hard for the underlying SSL library to choose the correct
966d16
+protocol version.  Fortunately, such servers are quite rare.
966d16
 
966d16
 @cindex SSL certificate, check
966d16
 @item --no-check-certificate
966d16
diff --git a/src/init.c b/src/init.c
966d16
index 4cee677..f160bec 100644
966d16
--- a/src/init.c
966d16
+++ b/src/init.c
966d16
@@ -1488,6 +1488,8 @@ cmd_spec_secure_protocol (const char *com, const char *val, void *place)
966d16
     { "sslv2", secure_protocol_sslv2 },
966d16
     { "sslv3", secure_protocol_sslv3 },
966d16
     { "tlsv1", secure_protocol_tlsv1 },
966d16
+    { "tlsv1_1", secure_protocol_tlsv1_1 },
966d16
+    { "tlsv1_2", secure_protocol_tlsv1_2 },
966d16
   };
966d16
   int ok = decode_string (val, choices, countof (choices), place);
966d16
   if (!ok)
966d16
diff --git a/src/main.c b/src/main.c
966d16
index 9cbad9f..3d50dad 100644
966d16
--- a/src/main.c
966d16
+++ b/src/main.c
966d16
@@ -625,7 +625,7 @@ HTTP options:\n"),
966d16
 HTTPS (SSL/TLS) options:\n"),
966d16
     N_("\
966d16
        --secure-protocol=PR     choose secure protocol, one of auto, SSLv2,\n\
966d16
-                                SSLv3, and TLSv1.\n"),
966d16
+                                SSLv3, TLSv1, TLSv1_1 and TLSv1_2.\n"),
966d16
     N_("\
966d16
        --no-check-certificate   don't validate the server's certificate.\n"),
966d16
     N_("\
966d16
diff --git a/src/openssl.c b/src/openssl.c
966d16
index b3c31ce..141a8a3 100644
966d16
--- a/src/openssl.c
966d16
+++ b/src/openssl.c
966d16
@@ -40,6 +40,9 @@ as that of the covered work.  */
966d16
 #include <openssl/x509v3.h>
966d16
 #include <openssl/err.h>
966d16
 #include <openssl/rand.h>
966d16
+#if OPENSSL_VERSION_NUMBER >= 0x00907000
966d16
+#include <openssl/conf.h>
966d16
+#endif
966d16
 
966d16
 #include "utils.h"
966d16
 #include "connect.h"
966d16
@@ -176,6 +179,12 @@ ssl_init (void)
966d16
       goto error;
966d16
     }
966d16
 
966d16
+#if OPENSSL_VERSION_NUMBER >= 0x00907000
966d16
+  OPENSSL_load_builtin_modules();
966d16
+  ENGINE_load_builtin_engines();
966d16
+  CONF_modules_load_file(NULL, NULL,
966d16
+      CONF_MFLAGS_DEFAULT_SECTION|CONF_MFLAGS_IGNORE_MISSING_FILE);
966d16
+#endif
966d16
   SSL_library_init ();
966d16
   SSL_load_error_strings ();
966d16
   SSLeay_add_all_algorithms ();
966d16
@@ -197,6 +206,21 @@ ssl_init (void)
966d16
     case secure_protocol_tlsv1:
966d16
       meth = TLSv1_client_method ();
966d16
       break;
966d16
+#if OPENSSL_VERSION_NUMBER >= 0x10001000
966d16
+    case secure_protocol_tlsv1_1:
966d16
+      meth = TLSv1_1_client_method ();
966d16
+      break;
966d16
+    case secure_protocol_tlsv1_2:
966d16
+      meth = TLSv1_2_client_method ();
966d16
+      break;
966d16
+#else
966d16
+    case secure_protocol_tlsv1_1:
966d16
+      logprintf (LOG_NOTQUIET, _("Your OpenSSL version is too old to support TLSv1.1\n"));
966d16
+      goto error;
966d16
+    case secure_protocol_tlsv1_2:
966d16
+      logprintf (LOG_NOTQUIET, _("Your OpenSSL version is too old to support TLSv1.2\n"));
966d16
+      goto error;
966d16
+#endif
966d16
     default:
966d16
       abort ();
966d16
     }
966d16
diff --git a/src/options.h b/src/options.h
966d16
index 326123a..575e647 100644
966d16
--- a/src/options.h
966d16
+++ b/src/options.h
966d16
@@ -200,7 +200,9 @@ struct options
966d16
     secure_protocol_auto,
966d16
     secure_protocol_sslv2,
966d16
     secure_protocol_sslv3,
966d16
-    secure_protocol_tlsv1
966d16
+    secure_protocol_tlsv1,
966d16
+    secure_protocol_tlsv1_1,
966d16
+    secure_protocol_tlsv1_2
966d16
   } secure_protocol;		/* type of secure protocol to use. */
966d16
   bool check_cert;		/* whether to validate the server's cert */
966d16
   char *cert_file;		/* external client certificate to use. */