Two methods for obtaining https requests using phpcurl _ PHP Tutorial

Source: Internet
Author: User
Phpcurl can be used to obtain https requests. Phpcurl: two methods for obtaining https requests. phpcurl: two methods for obtaining https requests. This article mainly introduces two methods for obtaining https requests from phpcurl, this article provides two methods to obtain https requests without verifying the certificate: php curl

 Php curl: two methods for obtaining https requests

This article mainly introduces two methods for php curl to obtain https requests. This article provides code instances that are set to not verify the certificate and host, and set a correct certificate, for more information, see

Today, a colleague reported an error when using curl to initiate an https request: "SSL certificate problem, verify that the CA cert is OK. details: error: 14090086: SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed"

Obviously, a problem occurs during certificate verification.

Curl can be used in the following two ways:

Method 1: do not verify the certificate and host.

Before you execute curl_exec. Set option

The code is as follows:

$ Ch = curl_init ();

......

Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE );

Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE );

Method 2: Set a correct certificate.

The local ssl identification certificate is too old, resulting in incorrect link error ssl certificate.

We need to download the new ssl local discriminant file.

Put it in the program file directory

Add the following configuration for curl

The code is as follows:

Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, true );;

Curl_setopt ($ ch, CURLOPT_CAINFO, dirname (_ FILE _). '/cacert. pem ');

Success

(My verification failed... Error message: SSL certificate problem, verify that the CA cert is OK. Details: error: 14090086: SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed)

Http://www.bkjia.com/PHPjc/990993.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/990993.htmlTechArticlephp curl to get https request two methods php curl to get https request two methods this article mainly introduces php curl to get https request two methods, this article provides settings for not verifying the certificate...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.