欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

解决Win7下运行php Composer出现SSL报错的问题

shiping1 的头像
10

10月17日南京OSC源创会第40期开始报名,精美礼品等你到现场拿  

(执行 $ composer.bat create-project laravel/laravel laravelstudy4.2 4.2 --prefer-dist 出现如下问题
  [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
create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [package] [directory] [version]
)


Warning: readfile(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in Command line code on line 1
 
Warning: readfile(): Failed to enable crypto in Command line code on line 1
 
Warning: readfile(https://getcomposer.org/installer): failed to open stream: operation failed in Command line code on line 1
 


以前都在linux环境使用php composer。今天尝试在win7下运行composer却出现SSL报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
D:\data\www\mmoyu\symapp>php -f %phprc%\composer install
Loading composer repositories with package information
 
  [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
 
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-p
lugins] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--ver
bose] [-o|--optimize-autoloader]

 

没有安装CA证书导致的!!!

CA证书下载地址:http://curl.haxx.se/docs/caextract.html
或者 http://curl.haxx.se/ca/cacert.pem

然后修改php.ini文件  增加 一行 openssl.cafile= D:/xampp/php/verify/cacert.pem

1
openssl.cafile= D:/wamp/php/verify/cacert.pem

 

在大约 1010行处 代码如下
extension=php_openssl.dll
openssl.cafile= D:/xampp/php/verify/cacert.pem

就OK了~

cacert.pem 文件见附件 , 下载后改名为 cacert.pem 即可

来自 http://my.oschina.net/yearnfar/blog/346727


附件大小
Plain text icon cacert.pem989 个字节
普通分类: