composer problems and SSL errors: OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Failed to enable crypto

After having some hard time installing some packages with composer, i decided to give back some simple solutions for all of you.

First of all suppose you operate in a shared hosting environment where you are not able to mess with the openssl CA root certificates and change the paths.
So you can simply download locally (e.g. /home/kmak) this http://curl.haxx.se/ca/cacert.pem

After you install locally composer.phar you can create your composer.json by requiting your package:

e.g.

 php composer.phar require slim/slim

Then edit composer.json and add the following config section, so finally your composer.json will look like this:

{
    "config": {
        "cafile":"/home/kmak/cacert.pem"
    },
    "require": {
        "slim/slim": "^3.3"
    }
}

Now you can proceed like this:

 php composer.phar install

If you encouter further SSL certificate errors due to git attempting to clone some project, then you can do this:

 GIT_SSL_NO_VERIFY=TRUE php composer.phar install

Remember disabling SSL certificate verification is a major security issue and should be avoided if possible.

Cheers.