2

I am using OS X Yosemite

I ran the following command in Composer because Laravel fails to download and install properly all the time:

composer diagnose

result:

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: 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 github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" 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 ope  
  ration 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 

The main line I want to focus on is:

SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto

How can I fix this. I have tried several solutions on the web and none have worked. I am totally new to the use of the command line.

When downloading and installing Laravel with the following command: composer create-project laravel/laravel --prefer-dist can't I just manually download the stuff myself and place it in the correct folder to avoid this SSL problem?

Robert
  • 10,126
  • 19
  • 78
  • 130
  • Not duplicate, but [related question](http://stackoverflow.com/questions/14078182/openssl-file-get-contents-failed-to-enable-crypto) providing a solution for cUrl setting the right options. Maybe you just need to fix the configuration. – GolezTrol Aug 14 '15 at 23:12
  • I am using OS X so the above Windows solution did not work. – Robert Aug 15 '15 at 03:12
  • You also get this error when the mailserver uses an expired certificate. – Lexib0y Feb 14 '19 at 14:45

4 Answers4

6

Note: I am running OS X Yosemite. I believe this works with Mavericks too.

After looking a several answers and combining them mixing and matching etc. Here is a rough explanation on what I did.

  1. Open the command line and run:

locate cacert.pem

This will list all the locations where your certificates are.

My result:

/Applications/Adobe Dreamweaver CS6/Configuration/Certs/cacert.pem
/Applications/MAMP/Library/lib/python2.7/test/pycacert.pem
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/_vendor/requests/cacert.pem
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/test/pycacert.pem
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/test/test_asyncio/pycacert.pem
/Users/robert/.composer/cacert.pem
/opt/vagrant/embedded/cacert.pem
/usr/ssl/certs/cacert.pem
  1. I downloaded the most recent one from curl

http://curl.haxx.se/docs/caextract.html

  1. I made a directory in /usr/ssl/certs/

and put the downloaded cert there /usr/ssl/certs/cacert.pem

  1. I opened up my php.ini file and placed this line at the top of the file: openssl.cafile=/usr/ssl/certs/cacert.pem

  2. Restart apache (stop apache and start it again)

Everything worked out for me.

Now one thing that I do believe needs to be done is you need to tell the command line which PHP you are referring to. I am running PHP under XAMPP and not natively on my OS X. So the command line will think that you are referring to the native PHP on OS X and not the one running on XAMPP. This needs to be changed I believe for this to work. If not then it should be good.

As mentioned this solution worked for me.

Robert
  • 10,126
  • 19
  • 78
  • 130
2

I faced this issue while executing composer install in Magento 2 , on MAMP , Mac m1 the issue was fixed after I replaced the file in path : /Applications/MAMP/Library/OpenSSL/cert.pem with the pem file downloaded from the : http://curl.haxx.se/docs/caextract.html

hope this helps someone on .

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 28 '21 at 08:36
0

The easiest way without the need to change the php.ini file:

DEBIAN/UBUNTU:
# apt-get install ca-certificates
FEDORA:
# dnf install ca-certificates.noarch
CENTOS/REDHAT
# yum install ca-certificates.noarch

Source: https://linuxconfig.org/routines-ssl3-get-server-certificate-certificate-verify-failed

nekooee
  • 142
  • 2
  • 9
-2

Another possible reason is that the server's SSL cert has expired. If it is your server, check the /etc/apache2/ssl (for ubuntu). The certs usually last for 365 days. See 'https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04' on how to create one.

Britc
  • 623
  • 5
  • 8
  • I remember a few minths back in tech news that openssl had been found too not be secure and all certs needed to be updated. I guess mine did not update hence the error – Robert Sep 02 '15 at 11:44