public static function runTlsTest(&$error = null)
{
try
{
$url = 'https://tlstest.paypal.com/';
$result = false;
$client = self::getHttpClient($url);
$body = $client->request('GET')->getBody();
$adapterOptions = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_SSLVERSION => 6)
);
$curl_client = new Zend_Http_Client($url, $adapterOptions);
$curlBody = $curl_client->request('GET')->getBody();
if($body != 'PayPal_Connection_OK' && $curlBody != 'PayPal_Connection_OK')
{
// Bad Bad server, Neither PHP nor cURL support TLS1.2
$result = 1;
}
elseif($body != 'PayPal_Connection_OK')
{
// Server's PHP does not support TLS1.2
$result = 2;
}
elseif ($curlBody != 'PayPal_Connection_OK')
{
// cURL does not support TLS1.2
$result = 3;
}
else
{
// Both PHP and cURL support TLS1.2
$result = 4;
}
}
catch (Exception $e)
{
$error = $e->getMessage();
return false;
}
return $result;
}