[Solved] Composer SSL Certificate Failed


got this error when running composer on Windows with PHP 5.6

 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

Run this in console:

php -r "print_r(openssl_get_cert_locations());"

Mine got something like this:

    [default_cert_file] => f:\repo\winlibs_openssl_vc11_x86/cert.pem
    [default_cert_file_env] => SSL_CERT_FILE
    [default_cert_dir] => f:\repo\winlibs_openssl_vc11_x86/certs
    [default_cert_dir_env] => SSL_CERT_DIR
    [default_private_dir] => f:\repo\winlibs_openssl_vc11_x86/private
    [default_default_cert_area] => f:\repo\winlibs_openssl_vc11_x86
    [ini_cafile] =>
    [ini_capath] =>

but I have no “f:\repo” directory so it was pointing to wrong location.

To fix this, add this line to PHP.ini


Or download cacert.pem from http://curl.haxx.se/ca/cacert.pem
and add this line to PHP.ini