1

i'm trying to make post to an external url using curl, the externa page use https, here is the desc of the server i'm using

Server Apache/2.2.11 (Win32) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.3.0

the external url make a redirect to another url that i send in the post, but everytime i try i get this error

curl_errno=35 (Unknown SSL protocol error in connection to [secure site]:443)

so i check the firebug for the response and it say

Failed to load source for: http://localhost/3Party/PHP_VPC_3Party_Auth_Capture_Order_DO.php

Here is the code I'm using

ob_start();

// initialise Client URL object
$ch = curl_init();
// set the URL of the VPC

curl_setopt ($ch, CURLOPT_URL, $vpcURL);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $this->postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec ($ch);
if (curl_error($ch)) {
    $this->errorMessage = 
        "curl_errno=". curl_errno($ch) . " (" . curl_error($ch) . ")";
}
curl_close ($ch);
hakre
  • 193,403
  • 52
  • 435
  • 836
Castro Roy
  • 7,623
  • 13
  • 63
  • 97

3 Answers3

6

I think the problem is the fact that you are trying to access an "http" URL (instead of "https") on port 443.

You can also try setting the SSL version manually:

curl_setopt($ch, CURLOPT_SSLVERSION, 3);

Replace 3 with whatever SSL version the remote server is using.

netcoder
  • 66,435
  • 19
  • 125
  • 142
  • Then what is: Failed to load source for: "`http`://localhost/3Party/PHP_VPC_3Party_Auth_Capture_Order_DO.php" – netcoder Nov 02 '10 at 12:56
  • now that you talk about that, the fact that i'm trying to redirect to an http url could be the problem, is that posible? – Castro Roy Nov 02 '10 at 12:57
  • this is what i see in the response when i go to the net tab of the firebug – Castro Roy Nov 02 '10 at 13:05
  • And what is the URL you are trying to access ($vpcURL)? The other common causes for this error are: bad protocol version, bad cipher or bad SSL key. – netcoder Nov 02 '10 at 13:14
  • ok, $vpcURL = https://banamex.dialectpayments.com/vpcpay, is https as you can se, if i make a normal post, from a form, it works, but i need to make it work with curl, can you tray to make a curl post to this url, just to see what happens – Castro Roy Nov 02 '10 at 13:41
  • I'm able to access this URL with cURL from my machine with no problem (PHP 5.3.3, Ubuntu 10.10, Apache 2.2.16, OpenSSL 0.9.8). It seems the problem is with your setup, you may want to try upgrading/reinstalling OpenSSL. – netcoder Nov 02 '10 at 14:08
  • Server Apache/2.2.11 (Win32) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.3.0, this is the server i'm using, wampserver2.0, do you think i need to upgrade or reinstall??, or is a problem that i'm using windows as OS – Castro Roy Nov 02 '10 at 14:41
  • i update my server, no it look like this Apache/2.2.16 (Win32) mod_ssl/2.2.16 OpenSSL/0.9.8o PHP/5.3.3, but i still get the same error (curl_errno 35 Unknown SSL protocol error in connection to banamex.dialectpayments.com:443) – Castro Roy Nov 03 '10 at 19:52
  • could be a problem of Linux and Windows ?? – Castro Roy Nov 03 '10 at 19:54
  • It could be. Try manually setting the SSL version. (See my edited answer). – netcoder Nov 03 '10 at 20:05
  • I appreciate the time you spend to answer my questions, thanks a lot, but how can i know the ssl version of the remote server – Castro Roy Nov 04 '10 at 16:41
  • It's most likely SSLv3. But you can try them both (2 and 3), and see what happens. – netcoder Nov 04 '10 at 16:50
  • same result, think i'm goint to switch to linux, let me see what happen – Castro Roy Nov 04 '10 at 17:58
2

After a few weeks dealing with this issue, i was able to at least establish the connection, i don't know if it is the real answer but it works for me, i just added to the example above, the options to use proxy, just like this

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM );
curl_setopt($ch, CURLOPT_PROXY, 'my.proxy');
curl_setopt($ch, CURLOPT_PROXYPORT, 'my.port');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'domain\user:password');  

hope this can help

Castro Roy
  • 7,623
  • 13
  • 63
  • 97
1

It might also be tls/ssl version preference by the server. In this case, you have to try specify different version constants from here: https://curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html

E.g. what worked for me was:

curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1);
Vasily802
  • 1,703
  • 2
  • 18
  • 35