title: file_get_contents(): SSL operation failed with code 1, Failed to enable crypto
body: <p>I’ve been trying to access this particular REST service from a PHP page I’ve created on our server.  I narrowed the problem down to these two lines.  So my PHP page looks like this:</p>
  
  <pre><code>&lt;?php
  $response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&amp;SingleLine=3042+N+1050+W&amp;outFields=*&amp;outSR=102100&amp;searchExtent=&amp;f=json");
  
  echo $response; ?&gt;
  </code></pre>
  
  <p>The page dies on line 2 with the following errors:</p>
  
  <blockquote>
    <ul>
    <li>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
    ...php on line 2
    
    <ul>
    <li>Warning: file_get_contents(): Failed to enable crypto in ...php on
    line 2</li>
    <li>Warning:
    file_get_contents(<code>https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&amp;SingleLine=3042+N+1050+W&amp;outFields=*&amp;outSR=102100&amp;searchExtent=&amp;f=json</code>):
    failed to open stream: operation failed in ...php on line 2</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>We’re using a Gentoo server.  We recently upgraded to PHP version 5.6.  It was after the upgrade when this problem appeared.    </p>
  
  <p>I found when I replace the REST service with an address like <code>https://www.google.com</code>; my page works just fine.  </p>
  
  <p>In an earlier attempt I set <code>“verify_peer”=&gt;false</code>, and passed that in as an argument to file_get_contents, as described here:  <a href="https://stackoverflow.com/questions/15076819/file-get-contents-ignoring-verify-peer-false">file_get_contents ignoring verify_peer=&gt;false?</a>  But like the writer noted; it made no difference.  </p>
  
  <p>I’ve asked one of our server administrators if these lines in our php.ini file exist:</p>
  
  <ul>
  <li>extension=php_openssl.dll</li>
  <li>allow_url_fopen = On</li>
  </ul>
  
  <p>He told me that since we’re on Gentoo, openssl is compiled when we build; and it’s not set in the php.ini file.  </p>
  
  <p>I also confirmed that <code>allow_url_fopen</code> is working.  Due to the specialized nature of this problem; I’m not finding a lot of information for help.  Have any of you come across something like this?  Thanks.  </p>