Browse Source

Merge pull request #4837 from cs278/openssl-version-warning

Warning if OpenSSL does not support TLSv1.2
Jordi Boggiano 9 years ago
parent
commit
101fca9071
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/Composer/Command/DiagnoseCommand.php

+ 13 - 0
src/Composer/Command/DiagnoseCommand.php

@@ -453,6 +453,10 @@ EOT
             $errors['openssl'] = true;
         }
 
+        if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
+            $warnings['openssl_version'] = true;
+        }
+
         if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) {
             $warnings['apc_cli'] = true;
         }
@@ -570,6 +574,15 @@ EOT
                         $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
                         break;
 
+                    case 'openssl_version':
+                        // Attempt to parse version number out, fallback to whole string value.
+                        $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
+                        $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
+
+                        $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
+                        $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
+                        break;
+
                     case 'xdebug_loaded':
                         $text  = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
                         $text .= " Disabling it when using Composer is recommended.";