We're using composer to upgrade dependencies with Satis. After a recent server upgrade we were unable to do so. Narrowing down possible causes, we've discovered, that file_get_contents php function fails while trying to establish an ssl connection.
We're using the following script to test our ssl:
<?php
$url = 'https://satis.work.com/packages.json';
$contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'local_cert' => '/home/work/.ssl/deployer.pem',
]
];
$sslContext = stream_context_create($contextOptions);
$result = file_get_contents($url, false, $sslContext);
echo $result, "\n";
This is thrown:
PHP Warning: file_get_contents(): Unable to set local cert chain file `/home/work/.ssl/deployer.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in /home/omlook/test-ssl.php on line 12 PHP Warning: file_get_contents(): Failed to enable crypto in /home/work/test-ssl.php on line 12 PHP Warning: file_get_contents(https://satis.work.com/packages.json): failed to open stream: operation failed in /home/work/test-ssl.php on line 12
It is definitely not a problem with rights or file ownership, script can read .pem just fine. What's bewildering about this, is how the exact same script and .pem key work just fine in my local environment, and version differences aren't that significant, it seems.
Local environment:
PHP 7.0.18-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.18-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
OpenSSL 1.0.2g 1 Mar 2016
Server:
PHP 7.1.7-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Jul 7 2017 10:07:42) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.7-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
OpenSSL 1.1.0f 25 May 2017