/**
  * Test various combinations of SSL/TLS libraries.
  *
  * @dataProvider can_use_tls12_testcases
  * @param string $sslversion the ssl_version string.
  * @param string|null $uname uname string (or null if not relevant)
  * @param bool $expected expected result
  */
 public function test_can_use_tls12($sslversion, $uname, $expected)
 {
     // Populate curlinfo with whats installed on this php install.
     $curlinfo = curl_version();
     // Set the curl values we are testing to the passed data.
     $curlinfo['ssl_version'] = $sslversion;
     // Set uname to system value if none passed in test case.
     $uname = !empty($uname) ? $uname : php_uname('r');
     $this->assertSame($expected, \core\upgrade\util::can_use_tls12($curlinfo, $uname));
 }
Пример #2
0
/**
 * Checks for up-to-date TLS libraries.
 *
 * @param environment_results $result object to update, if relevant.
 * @return environment_results|null updated results or null if unoconv path is not executable.
 */
function check_tls_libraries(environment_results $result)
{
    global $CFG;
    if (!\core\upgrade\util::validate_php_curl_tls(curl_version(), PHP_ZTS)) {
        $result->setInfo('invalid ssl/tls configuration');
        $result->setStatus(false);
        return $result;
    }
    if (!\core\upgrade\util::can_use_tls12(curl_version(), php_uname('r'))) {
        $result->setInfo('ssl/tls configuration not supported');
        $result->setStatus(false);
        return $result;
    }
    return null;
}
Пример #3
0
 /**
  * Test various combinations of SSL/TLS libraries.
  *
  * @dataProvider can_use_tls12_testcases
  * @param string $sslversion the ssl_version string.
  * @param string|null $uname uname string (or null if not relevant)
  * @param bool $expected expected result
  */
 public function test_can_use_tls12($sslversion, $uname, $expected)
 {
     // Populate curlinfo with whats installed on this php install.
     $curlinfo = curl_version();
     // Set the curl values we are testing to the passed data.
     $curlinfo['ssl_version'] = $sslversion;
     $curlinfo['version_number'] = self::VALID_CURL_VERSION;
     // Set uname to system value if none passed in test case.
     $uname = !empty($uname) ? $uname : php_uname('r');
     $this->assertSame($expected, \core\upgrade\util::can_use_tls12($curlinfo, $uname));
     // Now set the curl version to outdated one.
     $curlinfo['version_number'] = self::INVALID_CURL_VERSION;
     // Tls12 should never be possible now curl version is bad.
     $this->assertFalse(\core\upgrade\util::can_use_tls12($curlinfo, $uname));
 }