Bug #67639 [NEW]: cURL returns HTTP 400 error when doing two back-to-back queries
| From: | jarkkohyvarinen at hotmail dot com | Date: | Thu, 17 Jul 2014 09:46:47 +0000 |
| Subject: | Bug #67639 [NEW]: cURL returns HTTP 400 error when doing two back-to-back queries | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186685@lists.php.net to get a copy of this message | ||
From: jarkkohyvarinen at hotmail dot com
Operating system: CentOS 6.5
PHP version: 5.5.14
Package: cURL related
Bug Type: Bug
Bug description:cURL returns HTTP 400 error when doing two back-to-back queries
Description:
------------
If I do two back-to-back queries to our server using two different
server aliases (pointing to same server) first query executes
successfully but second query always causes HTTP error 400.
Apache ssl_error_log has an "Hostname www.server.com provided via SNI
and hostname alias.server.com provided via HTTP are different"
describing the 400 error.
Our server has Apache 2.2.15, OpenSSL 1.0.1e and cURL 7.19.7.
---
Workaround is to use stream_context_create with SNI_enabled and
SNI_server_name options.
Test script:
---------------
function doCurl($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $code;
}
echo "HTTP Status: ".doCurl("https://www.server.com")."\n";
echo "HTTP Status: ".doCurl("https://alias.server.com")."\n";
Expected result:
----------------
HTTP Status: 200
HTTP Status: 200
Actual result:
--------------
HTTP Status: 200
HTTP Status: 400
--
Edit bug report at https://bugs.php.net/bug.php?id=67639&edit=1
--