PHP Curl 2 ways to get HTTPS requests _php Tutorial

Source: Internet
Author: User
Tags ssl certificate

PHP Curl 2 ways to get HTTPS requests


 PHP Curl 2 ways to get HTTPS requests

This article mainly introduces PHP curl to get HTTPS request 2 ways, this article is set to not verify the certificate and host, set a correct certificate two common practice code example, the need for friends can refer to the following

One colleague today 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, there was a problem validating the certificate.

There are 2 ways to use curl if the HTTPS request that you want to initiate is normal:

Method one, set to No authentication certificate and host.

Before Curl_exec () is executed. 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 Two, set a correct certificate.

The local SSL discriminant certificate is too old to cause the link error SSL certificate to be incorrect.

We need to download a new SSL local discriminant file

Put it in the Program Files directory

Curl adds the following configuration

The code is as follows:

curl_setopt ($ch, curlopt_ssl_verifypeer,true);

curl_setopt ($ch, Curlopt_cainfo,dirname (__file__). ' /cacert.pem ');

Done

(I have failed to verify ...) 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.html www.bkjia.com true http://www.bkjia.com/PHPjc/990993.html techarticle PHP Curl 2 ways to get HTTPS requests PHP Curl 2 ways to get HTTPS requests this article mainly introduces PHP curl gets HTTPS request of 2 methods, this article gives the set to not verify 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.