title: PHP Curl HTTPS SSL23_GET_SERVER_HELLO:tlsv1
body: <p>I'm not able to access via curl to a https site and I'm stuck. </p>
  
  <p>The url can be opened in the browser and is using the following secure connection: </p>
  
  <blockquote>
    <p>The connection to this site is encrypted and authenticated using a
    strong protocol (TLS 1.2), a strong key exchange (ECDHE_RSA with
    P-256), and a strong cipher (AES_128_GCM).</p>
  </blockquote>
  
  <p>Here the php cUrl script I'm using:</p>
  
  <pre><code>$curl = curl_init();
  curl_setopt($curl,CURLOPT_URL,$Org_Input); //$Org_Input
  curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'); 
  curl_setopt($curl, CURLOPT_AUTOREFERER, true); //updates the referrer
  curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
  curl_setopt($curl, CURLOPT_VERBOSE, 1);
  curl_setopt($curl, CURLOPT_HEADER, 1);  
  curl_setopt($curl, CURLOPT_SSLVERSION, 6);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
  $response= curl_exec($curl);
  if (FALSE === $response) {
     echo "cUrl Error: " . curl_error($curl) . "&lt;br&gt;&lt;br&gt;";
  }
  </code></pre>
  
  <p>The script worked previously with the http url and now causes a problem if the url gets redirected to https. I believe it's linked to curl_setopt($curl, CURLOPT_SSLVERSION, 6);</p>
  
  <p>I tried with the script </p>
  
  <pre><code>for($i=0;$i&lt;=6;$i++) {
          //if($i==2) continue;
          $ch = curl_init($Org_Input);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_SSLVERSION, $i);
          if(curl_exec($ch) === false)
                  echo $i.': ' . curl_error($ch) . "&lt;br&gt;";
          else
                  echo $i.': works&lt;br&gt;';
          echo "\n";
          curl_close($ch);
  }   
  </code></pre>
  
  <p>And I get the following error messages:</p>
  
  <p>0: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version</p>
  
  <p>1: error:1409442E:SSL routines:SSL3_READ_BYTES:tlsv1 alert protocol version</p>
  
  <p>2: Unknown SSL protocol error in connection to www.example.com:443 </p>
  
  <p>3: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure</p>
  
  <p>4: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version</p>
  
  <p>5: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version</p>
  
  <p>6: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version</p>
  
  <p>As the website is using "TLS 1.2" for secure connection I believe the 6 is the right value as it stands for "CURL_SSLVERSION_TLSv1_2"</p>
  
  <p>But then I'm stuck with the error response: "1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version"</p>
  
  <p><strong>Somebody has any idea what could be the issue?</strong></p>
  
  <p>cUrl Version: 7.21.0
  Open SSL version: OpenSSL 0.9.8q 2 Dec 2010
  openssl version number: 9470239</p>