没有不值得去解决的问题,也没有不值得去学习的技术!

Fixing the “Curl error: #60 – SSL certificate problem: unable to get local issuer certificate” for HTTPS Requests With a Yii 2 HTTP Client Extension on Windows 10 64-Bit

Yii 2 HTTP client extension making an HTTPS request throws the error: "Curl error: #60 - SSL certificate problem: unable to get local issuer certificate"

1. When making an HTTPS request using the Yii 2 HTTP client extension, the following error occurred: “Curl error: #60 – SSL certificate problem: unable to get local issuer certificate”, as shown in Figure 1.

Yii 2 HTTP client extension making an HTTPS request throws the error: "Curl error: #60 - SSL certificate problem: unable to get local issuer certificate"
Figure 1

2. By configuring the client through the application component, I removed the ‘transport’ => ‘yii\httpclient\CurlTransport’ configuration option, as shown in Figure 2.

Configuring the client through the application component and removing the 'transport' => 'yii\httpclient\CurlTransport' configuration option
Figure 2

3. The Yii 2 HTTP client extension now makes HTTPS requests normally, as shown in Figure 3.

Yii 2 HTTP client extension making an HTTPS request normally
Figure 3

4. Checking the documentation at https://github.com/yiisoft/yii2-httpclient/blob/master/docs/guide-zh-CN/usage-transports.md reveals that CurlTransport supports advanced features like batch requests. Therefore, because batch requests are required, the client’s transport must be configured as CurlTransport, as shown in Figure 4.

Checking the documentation: https://github.com/yiisoft/yii2-httpclient/blob/master/docs/guide-zh-CN/usage-transports.md , CurlTransport supports advanced features such as batch requests (therefore, because batch requests are needed, the transport used by the client must be configured as CurlTransport)
Figure 4

5. I opened the URL https://curl.haxx.se/docs/caextract.html, downloaded and extracted cacert.pem (a clean file format/data), and copied it to C:\php-7.1.12\extras\ssl\cacert.pem, as shown in Figure 5.

Open the URL: https://curl.haxx.se/docs/caextract.html , download and extract cacert.pem (a clean file format/data) here, and copy it to: C:\php-7.1.12\extras\ssl\cacert.pem
Figure 5

6. I edited php.ini, changed ;curl.cainfo = to curl.cainfo = “C:\php-7.1.12\extras\ssl\cacert.pem”, and restarted PHP, as shown in Figure 6.

Edit php.ini, change ;curl.cainfo = to curl.cainfo = "C:\php-7.1.12\extras\ssl\cacert.pem", and restart PHP
Figure 6

7. Because this is a RESTful application, Cookies are already disabled, so Cookies are only transmitted as request headers, as shown in Figure 7.

Because it is a RESTful application, Cookies are already disabled, so Cookies are only transmitted as request headers
Figure 7

8. By configuring the client through the application component, I restored the ‘transport’ => ‘yii\httpclient\CurlTransport’ configuration option. The HTTPS request now works normally, as shown in Figure 8.

Configuring the client through the application component, restoring the 'transport' => 'yii\httpclient\CurlTransport' configuration option, and the HTTPS request works normally
Figure 8

9. Checking the Debug log information shows that the Cookie settings are as expected, as shown in Figure 9.

Cookie: login_chinamcloud_id=13980074657; login_chinamcloud_tid=c7a8106ea2da1d5d5c01a13234c69ea8

Checking the Debug log information, the Cookie settings are as expected
Figure 9

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系