I have a php script that runs from command line and makes an https request to paypal, using curl. It works fine if I run it from a web page. It fails if I run it from CLI. The error I get from the CLI:

* About to connect() to api-3t.sandbox.paypal.com port 443
* Trying 216.113.191.88... * connected
* Connected to api-3t.sandbox.paypal.com (216.113.191.88) port 443
* successfully set certificate verify locations:
* CAfile: /usr/share/ssl/certs/ca-bundle.crt
CApath: none
* Unknown SSL protocol error in connection to api-3t.sandbox.paypal.com:443
* Closing connection #0
*** glibc detected *** free(): invalid pointer: 0x00dc8c80 ***
Aborted

Again, if I view the script from the browser it runs fine, no errors..

I also tried running it as root on the CLI in case it was a permissions problem.

When I echo phpinfo() from the CLI, it looks the same as when I print it in the browser. I even threw in an obscure setting in there to compare it with both. CURL shows up in both:

CURL support => enabled
CURL Information => libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.3 libidn/0.5.6


More info:

$ php -v
PHP 5.1.4 (cli) (built: Jun 8 2006 18:09:19)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

$ php -m
[PHP Modules]
ctype
curl
date
dom
ftp
gd
hash
iconv
libxml
ming
mysqli
pcre
PDO
posix
Reflection
session
SimpleXML
soap
SPL
SQLite
standard
tokenizer
xml
xmlreader
xmlwriter
zlib