Curl HTTPS request Solution

Source: Internet
Author: User

When using curl to initiate an HTTPS request, the following error occurs: "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

$ 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.

Http://curl.haxx.se/ca/cacert.pem

Put inProgramFile directory

Add the following configuration for Curl

Curl_setopt ($ ch, curlopt_ssl_verifypeer, true );;
Curl_setopt ($ ch, curlopt_cainfo, dirname (_ file _). '/cacert. pem ');

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.