PHP CURL SSL won't work or connect

I spent so much time debugging this, most sites don't tell you a very important option to use with CURL and you will only find out this is the problem by running the PHP script from the command line you get the following output that shows the issue (I don't see any way to get this output from Apache itself).

* About to connect() to ip.ip.ip.ip port 25000
*   Trying ip.ip.ip.ip... * connected
* Connected to ip.ip.ip.ip (ip.ip.ip.ip) port 25000
* successfully set certificate verify locations:
*   CAfile: /usr/share/ssl/certs/ca-bundle.crt
  CApath: none
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*      subject: /C=--/ST=SomeState/L=SomeCity/O=SomeOrganization/OU=SomeOrganizationalUnit/CN=domain.com/emailAddress=us@domain.com
*      start date: 2010-10-20 04:23:10 GMT
*      expire date: 2011-10-20 04:23:10 GMT
* SSL: certificate subject name 'domain.com' does not match target host name 'ip.ip.ip.ip'
* Closing connection #0
Content-type: text/html
X-Powered-By: PHP/4.3.9

The solution

Add the following to your CURL options:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);

The VERIFYHOST option is what I was missing.

 

 


Tags:

php, curl, ssl, connecti, debugging, sites, output, apache, ip, successfully, certificate, verify, locations, cafile, usr, certs, ca, bundle, crt, capath, dhe, rsa, aes, sha, server, somestate, somecity, someorganization, ou, someorganizationalunit, cn, domain, emailaddress, gmt, expire, content, text, html, powered, curl_setopt, ch, curlopt_ssl_verifypeer, curlopt_ssl_verifyhost, verifyhost,

Latest Articles

  • Why SMART is not smart at all and doesn't properly predict disk errors that cause a kernel panic or crash
  • scp: ambiguous target error and solution
  • VirtualBox How To Add iSCSI Storage using VBoxManage
  • iSCSI on Centos 7 Configuration and Setup Guide for Initiator and Target
  • Python and BeautifulSoup4's BS4's Decompose Method To Remove Unwanted Inner Tags
  • httpd AH00534: httpd: Configuration error: No MPM loaded. solution
  • bash script to remove modules from httpd.conf that are not actually installed
  • bash scripting how to create a function
  • Centos 7 PHP MySQL Not Working Solution
  • Bash How To Cut or Split Natively And Get The LAST Field
  • Bash Script How To Manipulate Text/Strings By Searchig and Replacing Natively
  • How Does Cisco CUCM (Cisco Unified Communication Manager) Work?
  • What DNS Options Does Active Directory Offer in Windows Server 2008,2012,2016 ?
  • syntax error, unexpected T_SL in PHP Solution
  • grep regular expression match number range between specific numbers
  • bash how to print out lines of text within a range from the first occurrence
  • bash script how to to check LAN computers for open ports
  • MySQL Using mytop Debug Source of High IO and Slow Performance
  • How To Mathematically Convert and Calculate Binary Value To Decimal Value
  • systemd management using systemctl and journalctl to check systemd logs