JamborYao / acn-content

0 stars 5 forks source link

aog-cognitive-services-php-certification #17

Closed JamborYao closed 7 years ago

JamborYao commented 7 years ago

Please consider to use a new template to write this type article. not use the same structure with op's.

v-tawe commented 7 years ago

It's a troubleshooting article, so I still use the format just like "issue----solution"; And due to the article is too simple, I add the content about "Why me meet the error" and "some discription about CA which we use in solution" to rich the article. Please help me to confirm whether it's suitable.

PHP调用认知服务证书认证问题

问题描述

在使用 PHP 的 http 客户端工具(如 Guzzle)调用认知服务时出现证书认证问题,错误信息如下:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate

解决方法

此问题的出现是由于没有配置信任的服务器 HTTPS 验证。默认, cURL 被设为不信任任何 CAs,因此,这就是无法访问相关服务器的原因。解决该问题的最好方法是指定一组默认的受信任的 CAs。

所以此问题可以通过下载证书的方式进行解决,具体操作方法如下:

  1. 下载证书保存到本地,下载地址:https://curl.haxx.se/ca/cacert.pem
  2. 配置 php.ini 文件:curl.cainfo =<filepath>/cacert.pem
  3. 重启 Apache 服务器,问题解决。