php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29958 cURL https request fails when connecting to IP (not domain)
Submitted: 2004-09-02 21:21 UTC Modified: 2004-09-03 20:26 UTC
From: ryan dot hansen at usa dot net Assigned:
Status: Not a bug Package: cURL related
PHP Version: 4.3.8 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 + 30 = ?
Subscribe to this entry?

 
 [2004-09-02 21:21 UTC] ryan dot hansen at usa dot net
Description:
------------
When attempting to connect to an IP address (not a domain) over SSL using cURL (7.9.5), there is no response, no errors, etc.  I get nothing.  When I test the same script with a domain (a different server), I get a response as expected.  When I test it with the correct IP address over HTTP (non-secure), I also get a response as expected.

The problem, however, is that the server that I have to connect to for the app I'm building does not have a domain, only an IP address and it must be a secure connection.  

I admit that I could be missing something, but I can't figure out what it is and I've tested it pretty thoroughly under multiple scenarios.

Reproduce code:
---------------
$postdata = "POST DATA TO POST TO SERVER";

// use appropriate IP, of course
$ch = curl_init("https://xxx.xxx.xxx.xxx"); 
curl_setopt($ch, CURL_POST, 1);
curl_setopt($ch, CURL_POSTFIELDS, $postdata);
curl_setopt($ch, CURL_ERROR, 1);
curl_setopt($ch, CURL_RETURNTRANSFER, 1);
$retval = curl_exec($ch);
curl_close($ch);

// print result for testing
echo $retval;
exit;


Expected result:
----------------
The echo statement should print the web page data from the IP to the screen, and it does when I test with non-secure IP or domain.

Actual result:
--------------
Nothing. The echo statement doesn't seem to print anything.  No cURL errors, no results, no PHP warnings or errors.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-02 21:28 UTC] ryan dot hansen at usa dot net
I should mention that this same code DOES work on a different requesting server (FreeBSD 4.4; PHP 4.2.3)
 [2004-09-03 14:38 UTC] daniel at haxx dot se
curl 7.9.5 was released some 30 months ago. Do I need to say more?
 [2004-09-03 15:01 UTC] derick@php.net
Good point Daniel, marking this as bogus. Upgrade first!
 [2004-09-03 20:26 UTC] ryan dot hansen at usa dot net
Nope, it's not a problem with the curl version (as I knew it wouldn't be).  I upgraded to 7.12 and still had the problem.  Turns out I had to set the CURLOPT_VERIFYHOST to false so it wouldn't try to resolve the domain name with the SSL certificate.

I don't know if you'd still call it a bug, but this would have been much easier to solve if I had received some kind of error message to that effect.  I had PHP error messages turned on and the CURLOPT_ERROR option turned on, so I should have gotten something, but I didn't.

Anyway, it's fixed now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC