Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer update fails while updating from packagist

While executing composer install/update I have got the following error from openssl:

The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Failed to enable crypto failed to open stream: operation failed https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

I am using:

  1. PHP 5.6.3 (cli) (built: Nov 17 2014 15:16:53)
  2. XAMPP stack 5.6.3-0
  3. ubuntu 14.04

composer diag shows:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json"  file  could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Checking disk free space: OK
Checking composer version: 

[Composer\Downloader\TransportException]
The "https://getcomposer.org/version" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed

php -r 'var_dump(openssl_get_cert_locations());' shows:

array(8) {
["default_cert_file"]=>
string(33) "/opt/lampp/share/openssl/cert.pem"
["default_cert_file_env"]=>
string(13) "SSL_CERT_FILE"
["default_cert_dir"]=>
string(30) "/opt/lampp/share/openssl/certs"
["default_cert_dir_env"]=>
string(12) "SSL_CERT_DIR"
["default_private_dir"]=>
string(32) "/opt/lampp/share/openssl/private"
["default_default_cert_area"]=>
string(24) "/opt/lampp/share/openssl"
["ini_cafile"]=>
string(0) ""
["ini_capath"]=>
string(0) ""
}

For php 5.5.19 everything is Ok.

like image 248
yuklia Avatar asked Nov 29 '14 20:11

yuklia


People also ask

Can not composer update?

Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer. json via rm -rf vendor && composer update -v when troubleshooting, excluding any possible interferences with existing vendor installations or composer.

How do I update the composer package to the latest version?

To update your packagesNavigate to the root of your git repo, where your composer. json file is. Run composer update (on your local machine) to update the required packages and re-generate a composer.

How do I increase composer memory limit?

Use the format “128M” for megabyte or “2G” for gigabyte. You can use the value “-1” to ignore the memory limit completely. Another way would be to increase the PHP memory limit: php -d memory_limit=512M composer.

How to fix PHP Composer package update not working?

php composer.phar install --prefer-dist All the packages will be refreshed by composer using the cached versions if they are the latest. Now check and see if your problem is resolved by checking your package versions. You should also test a php composer.phar update after this when a new package update is available, and see if it works.

What version of composer is private Packagist compatible with?

Private Packagist is fully compatible with both Composer versions 1 and 2, you do not need to make any changes to your Private Packagist configuration when upgrading to Composer 2.0. In order to upgrade to a current preview release of Composer 2.0 you need to run the following command:

How do I reinstall a package using composer?

In order to reinstall packages using composer, you can do the following: Step 1: Backup your vendor folder under your app root, and delete all files in the vendor folder, except .gitignore if it exists. Step 2: Backup your composer.lock file on your app root, and delete it. Step 3: Run the following command from your app root.

How do I upgrade to the latest release of composer?

In order to upgrade to a current preview release of Composer 2.0 you need to run the following command: composer.phar self-update --2 If you want to switch back to version 1 you can either use composer self-update --rollback right afterwards or composer self-update --1 at any any later point.


2 Answers

I found a solution to this

I'm running:
FreeBSD 10.1
Apache2.4
PHP 5.6.3

To find the CA file I ran this command

> locate cacert.pem

Result was:
/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem

Then open the php.ini file and
change this:

;openssl.cafile=

To this:

openssl.cafile=/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem

Note: This directive is only available on php 5.6.x

Then restart Apache

like image 173
Manuel Ochoa Avatar answered Oct 16 '22 15:10

Manuel Ochoa


I am using Mac OS Sierra and when I was trying to update the composer using the command /usr/local/bin/composer self-update I kept getting the error:

[Composer\Downloader\TransportException]                                                          
  The "https://getcomposer.org/version" file could not be downloaded: SSL operation failed with co  
  de 1. OpenSSL Error messages:                                                                     
  error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed                 
  Failed to enable crypto                                                                           
  failed to open stream: operation failed  

I fixed it following these steps:

1) Create the local database using the command:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

2) Locate the cert file:

locate cacert.pem 

3) Check the location of the php.ini file:

php --ini

4) If the 'Loaded Configuration File' for php.ini file is showing as (none), copy the file /etc/php.ini.default to /etc/php.ini:

sudo cp /etc/php.ini.default /etc/php.ini

5) Open the php.ini file and edit the ;openssl.cafile= line by uncommenting it and appending the link to the cert file location:

openssl.cafile=/Users/me/.composer/cacert.pem

Thats it. Now, when you run the composer update, it will work fine.

like image 12
Neel Avatar answered Oct 16 '22 16:10

Neel