3

My Apache process segfaults whenever I call curl_exec() from PHP with an "https://" URL.

If I use http instead of https as the URL transport, it works perfectly, so I know curl and the other curl options are correct.

I can use curl from the command-line on that server using the https version of the URL and it works perfectly, so I know the remote server is responding correctly, the cert isn't expired, etc..

My server is:

Linux 2.6.32-21-server #32-Ubuntu SMP Fri Apr 16 09:17:34 UTC 2010 x86_64 GNU/Linux

My Apache version is:

Server version: Apache/2.2.14 (Ubuntu)
Server built:   Apr 13 2010 20:21:26

My PHP version is:

PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:03:45) 
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

My PHP curl module info is:

cURL support => enabled
cURL Information => 7.19.7
Age => 3
Features
AsynchDNS => No
Debug => No
GSS-Negotiate => Yes
IDN => Yes
IPv6 => Yes
Largefile => Yes
NTLM => Yes
SPNEGO => No
SSL => Yes
SSPI => No
krb4 => No
libz => Yes
CharConv => No
Protocols => tftp, ftp, telnet, dict, ldap, ldaps, http, file, https, ftps
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/0.9.8k
ZLib Version => 1.2.3.3
paolo
  • 387
  • 3
  • 14
Jason Cohen
  • 1,067
  • 3
  • 14
  • 21
  • I'm having the same problem also. Did you manage to find a solution? –  Jan 08 '12 at 22:07
  • Does that mean you don't get a segfault using a browser to access HTTPS? – symcbean Mar 18 '17 at 20:49
  • Assuming that you have checked that all your rpms are up to date, if I were you, I'd be running a backtrace on the core file using gdb. – symcbean Jun 24 '17 at 22:21
  • 3
    I'm voting to close this question as off-topic because Community bumped it but a question about a seven year old segfault is highly unlikely to help anyone now. – ceejayoz Dec 05 '17 at 00:23

3 Answers3

0

Consider adding the following:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

Now, in order to see what is going on use var_dump() or error_log(). It should be something like this:

var_dump(curl_exec($ch));

OR

error_log(curl_exec($ch));

If you use error_log() you should find the trace in the error_log file.

If that fails you have no choice, except using strace

Giacomo1968
  • 3,522
  • 25
  • 38
Iulian
  • 408
  • 1
  • 3
  • 8
0

method1:

You could try build curl lastest version 7.49.1 by hand,then change soft link into old curl,normally it is located /usr/bin/curl and curl-config. then fix lib into /etc/ld.conf.d/local.conf and run command "ldconfig"

method2:

First of all, the standard CentOS 6 version of curl/libcurl is recent enough that you won't need the old compat packages (libcurl7155 etc.).

The easiest way to install the updated curl from my repo is to install my repo release package http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm

rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm

and then edit the file /etc/yum.repos.d/city-fan.org.repo to change the line enabled=1 to enabled=0 to prevent pulling in anything from there when you're not expecting it.

You can then see what would happen if you updated curl from my repo by doing: yum --enablerepo=city-fan.org update curl

At this point you can see what would be installed/removed (I'd expect it to install/update a few libraries as well as curl and libcurl, and not remove anything), and say "yes" or "no" to the update. The updated version of curl should work fine with everything in CentOS 6.

I did exactly this and after restarting Apache I'm pleased to say PHP is also now using the new version.

Kingstar
  • 21
  • 1
  • before link is ok,you can search above package by google. and refer to :https://serverfault.com/questions/321321/upgrade-curl-to-latest-on-centos/686264 – Kingstar Mar 28 '18 at 01:29
  • 1,https://www.digitalocean.com/community/questions/how-to-upgrade-curl-in-centos6 2,https://serverfault.com/questions/321321/upgrade-curl-to-latest-on-centos/686264 – Kingstar Apr 03 '18 at 06:45
  • down vote This is an old question, but it is still one the first results in google search, so I'd like post the solution that got my problem solved. 1) create a new file /etc/yum.repos.d/city-fan.repo 2) Paste the following contents: [CityFan] name=City Fan Repo baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel$releasever/$basearch/ enabled=1 gpgcheck=0 3) type: yum clean all yum install curl 4) And it's done. – Kingstar Apr 03 '18 at 06:45
-1

For me playing with the various PHP curl options available with curl_setopt() has helped me in the past. Try changing CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to false, for starters.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78