Blame SOURCES/stunnel-5.56-default-tls-version.patch

72fc89
--- stunnel-5.56/src/prototypes.h.default-tls-version	2020-04-06 11:22:24.480280384 +0200
72fc89
+++ stunnel-5.56/src/prototypes.h	2020-04-06 11:21:05.407597053 +0200
72fc89
@@ -897,6 +897,9 @@ ICON_IMAGE load_icon_default(ICON_TYPE);
72fc89
 ICON_IMAGE load_icon_file(const char *);
72fc89
 #endif
72fc89
 
72fc89
+#define USE_DEFAULT_TLS_VERSION ((int)-2) /* Use defaults in OpenSSL
72fc89
+                                             crypto policies */
72fc89
+
72fc89
 #endif /* defined PROTOTYPES_H */
72fc89
 
72fc89
 /* end of prototypes.h */
72fc89
--- stunnel-5.56/src/options.c.default-tls-version	2020-04-06 18:58:48.947214149 +0200
72fc89
+++ stunnel-5.56/src/options.c	2020-04-08 15:45:18.093520780 +0200
72fc89
@@ -3123,8 +3123,9 @@ NOEXPORT char *parse_service_option(CMD
72fc89
             return "Invalid protocol version";
72fc89
         return NULL; /* OK */
72fc89
     case CMD_INITIALIZE:
72fc89
-        if(section->max_proto_version && section->min_proto_version &&
72fc89
-                section->max_proto_version<section->min_proto_version)
72fc89
+        if(section->max_proto_version != USE_DEFAULT_TLS_VERSION
72fc89
+                && section->min_proto_version != USE_DEFAULT_TLS_VERSION
72fc89
+                && section->max_proto_version<section->min_proto_version)
72fc89
             return "Invalid protocol version range";
72fc89
         break;
72fc89
     case CMD_PRINT_DEFAULTS:
72fc89
@@ -3142,7 +3143,10 @@ NOEXPORT char *parse_service_option(CMD
72fc89
     /* sslVersionMax */
72fc89
     switch(cmd) {
72fc89
     case CMD_SET_DEFAULTS:
72fc89
-        section->max_proto_version=0; /* highest supported */
72fc89
+        section->max_proto_version=USE_DEFAULT_TLS_VERSION; /* use defaults in
72fc89
+                                                               OpenSSL crypto
72fc89
+                                                               policies.Do not
72fc89
+                                                               override it */
72fc89
         break;
72fc89
     case CMD_SET_COPY:
72fc89
         section->max_proto_version=new_service_options.max_proto_version;
72fc89
@@ -3173,7 +3177,10 @@ NOEXPORT char *parse_service_option(CMD
72fc89
     /* sslVersionMin */
72fc89
     switch(cmd) {
72fc89
     case CMD_SET_DEFAULTS:
72fc89
-        section->min_proto_version=TLS1_VERSION;
72fc89
+        section->min_proto_version=USE_DEFAULT_TLS_VERSION; /* use defaults in
72fc89
+                                                               OpenSSL crypto
72fc89
+                                                               policies. Do not
72fc89
+                                                               override it */
72fc89
         break;
72fc89
     case CMD_SET_COPY:
72fc89
         section->min_proto_version=new_service_options.min_proto_version;
72fc89
--- stunnel-5.56/src/ctx.c.default-tls-version	2019-10-24 10:48:11.000000000 +0200
72fc89
+++ stunnel-5.56/src/ctx.c	2020-04-06 11:16:48.406406794 +0200
72fc89
@@ -143,17 +143,29 @@ int context_init(SERVICE_OPTIONS *sectio
72fc89
         section->ctx=SSL_CTX_new(TLS_client_method());
72fc89
     else /* server mode */
72fc89
         section->ctx=SSL_CTX_new(TLS_server_method());
72fc89
-    if(!SSL_CTX_set_min_proto_version(section->ctx,
72fc89
-            section->min_proto_version)) {
72fc89
-        s_log(LOG_ERR, "Failed to set the minimum protocol version 0x%X",
72fc89
-            section->min_proto_version);
72fc89
-        return 1; /* FAILED */
72fc89
+
72fc89
+    if (section->min_proto_version == USE_DEFAULT_TLS_VERSION) {
72fc89
+        s_log(LOG_INFO, "Using the default TLS version as specified in \
72fc89
+                OpenSSL crypto policies. Not setting explicitly.");
72fc89
+    } else {
72fc89
+        if(!SSL_CTX_set_min_proto_version(section->ctx,
72fc89
+                    section->min_proto_version)) {
72fc89
+            s_log(LOG_ERR, "Failed to set the minimum protocol version 0x%X",
72fc89
+                    section->min_proto_version);
72fc89
+            return 1; /* FAILED */
72fc89
+        }
72fc89
     }
72fc89
-    if(!SSL_CTX_set_max_proto_version(section->ctx,
72fc89
-            section->max_proto_version)) {
72fc89
-        s_log(LOG_ERR, "Failed to set the maximum protocol version 0x%X",
72fc89
-            section->max_proto_version);
72fc89
-        return 1; /* FAILED */
72fc89
+
72fc89
+    if (section->max_proto_version == USE_DEFAULT_TLS_VERSION) {
72fc89
+        s_log(LOG_INFO, "Using the default TLS version as specified in \
72fc89
+                OpenSSL crypto policies. Not setting explicitly");
72fc89
+    } else {
72fc89
+        if(!SSL_CTX_set_max_proto_version(section->ctx,
72fc89
+                    section->max_proto_version)) {
72fc89
+            s_log(LOG_ERR, "Failed to set the maximum protocol version 0x%X",
72fc89
+                    section->max_proto_version);
72fc89
+            return 1; /* FAILED */
72fc89
+        }
72fc89
     }
72fc89
 #else /* OPENSSL_VERSION_NUMBER<0x10100000L */
72fc89
     if(section->option.client)