title: Twilio: Uncaught exception 'Services_Twilio_HttpStreamException' with message 'Unable to connect to service'
body: <p>I am using this code in PHP to list SMS messages received to a certain number:</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  
  // Get the PHP helper library from twilio.com/docs/php/install
  require_once('twilio/Services/Twilio.php'); // Loads the library
  
  // Your Account Sid and Auth Token from twilio.com/user/account
  $sid = ""; 
  $token = ""; 
  $client = new Services_Twilio($sid, $token);
  
  $messages = $client-&gt;account-&gt;messages-&gt;getIterator(0, 50, array(
      'To' =&gt; $_SERVER['QUERY_STRING'] 
  )); 
  
  foreach ($messages as $message) { 
      echo "&lt;tr&gt;&lt;td&gt;" . $message-&gt;from . "&lt;/td&gt;&lt;td&gt;" . $message-&gt;date_sent . "&lt;/td&gt;&lt;td&gt;" . $message-&gt;body . "&lt;/td&gt;&lt;/tr&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>but it is outputting this error message:</p>
  
  <pre><code>Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /var/www/temp-sms.com/twilio/Services/Twilio/HttpStream.php on line 67
  
  Warning: file_get_contents(): Failed to enable crypto in /var/www/temp-sms.com/twilio/Services/Twilio/HttpStream.php on line 67
  
  Warning: file_get_contents(https://api.twilio.com/2010-04-01/Accounts/AC049b65c32bd0cad6a229b44719ac6116/Messages.json?Page=0&amp;PageSize=50&amp;To=%2B16466635449): failed to open stream: operation failed in /var/www/temp-sms.com/twilio/Services/Twilio/HttpStream.php on line 67
  
  Fatal error: Uncaught exception 'Services_Twilio_HttpStreamException' with message 'Unable to connect to service' in /var/www/temp-sms.com/twilio/Services/Twilio/HttpStream.php:70 Stack trace: #0 [internal function]: Services_Twilio_HttpStream-&gt;__call('get', Array) #1 [internal function]: Services_Twilio_HttpStream-&gt;get('/2010-04-01/Acc...') #2 /var/www/temp-sms.com/twilio/Services/Twilio.php(260): call_user_func_array(Array, Array) #3 /var/www/temp-sms.com/twilio/Services/Twilio.php(236): Base_Services_Twilio-&gt;_makeIdempotentRequest(Array, '/2010-04-01/Acc...', 1) #4 /var/www/temp-sms.com/twilio/Services/Twilio/ListResource.php(125): Base_Services_Twilio-&gt;retrieveData('/2010-04-01/Acc...', Array) #5 /var/www/temp-sms.com/twilio/Services/Twilio/ListResource.php(179): Services_Twilio_ListResource-&gt;getPage(0, 50, Array, NULL) #6 [internal function]: Services_Twilio_ListResource-&gt;getPageGenerator(0, 50, Array, NULL) #7 /var/www/temp-sms.com/twilio/Services/Twilio/AutoPagingIterator.php(104): call_user_func_array(Array, Array in /var/www/temp-sms.com/twilio/Services/Twilio/HttpStream.php on line 70
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Installed <code>php5-curl</code> as suggested by @philnash and restarted.</p>
  
  <p>New error message:</p>
  
  <pre><code>Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'SSL certificate problem: self signed certificate in certificate chain' in /var/www/temp-sms.com/twilio/Services/Twilio/TinyHttp.php:119 Stack trace: #0 [internal function]: Services_Twilio_TinyHttp-&gt;__call('get', Array) #1 [internal function]: Services_Twilio_TinyHttp-&gt;get('/2010-04-01/Acc...') #2 /var/www/temp-sms.com/twilio/Services/Twilio.php(260): call_user_func_array(Array, Array) #3 /var/www/temp-sms.com/twilio/Services/Twilio.php(236): Base_Services_Twilio-&gt;_makeIdempotentRequest(Array, '/2010-04-01/Acc...', 1) #4 /var/www/temp-sms.com/twilio/Services/Twilio/ListResource.php(125): Base_Services_Twilio-&gt;retrieveData('/2010-04-01/Acc...', Array) #5 /var/www/temp-sms.com/twilio/Services/Twilio/ListResource.php(179): Services_Twilio_ListResource-&gt;getPage(0, 50, Array, NULL) #6 [internal function]: Services_Twilio_ListResource-&gt;getPageGenerator(0, 50, Array, NULL) #7 /var/www/temp-sms.com/twilio/Services/Twilio/AutoPagingIterator.php(104): in /var/www/temp-sms.com/twilio/Services/Twilio/TinyHttp.php on line 119
  </code></pre>