0

I've got a PHP cUrl session that works well with HTTP URLs but ends with an error 500 with https...

I've already tried to use

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

but it didn't work.

Here you have my code:

$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");  
curl_setopt($ch, CURLOPT_POSTFIELDS, $responseJson);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($responseJson))                                                                       
);
$output=curl_exec($ch);
$curl_info = curl_getinfo($ch);
curl_close($ch);

And here a print_r of $curl_info:

Array
(
    [url] => https://xxx
    [content_type] => text/html; charset=utf-8
    [http_code] => 500
    [header_size] => 291
    [request_size] => 280
   [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.474033
    [namelookup_time] => 0.004676
    [connect_time] => 0.005514
    [pretransfer_time] => 0.021116
    [size_upload] => 3082
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 6501
    [download_content_length] => 0
    [upload_content_length] => 3082
    [starttransfer_time] => 0.022492
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => xxx
    [certinfo] => Array
        (
        )

    [primary_port] => xxx
    [local_ip] => xxx
    [local_port] => xxx
)

Thank you very much for your help!!

Cettt
  • 11,460
  • 7
  • 35
  • 58
Mirien
  • 1
  • 2

2 Answers2

0

A 500 error is a generic error on the remote server, so probably nothing much that you can debug. You may need to contact the devs of the remote server to find out why their HTTPS site is giving a 500 error. – aynber

That was finally the right answer. The problem wasn't in my code but on server side.

Thank you for pointing me on the right direction!

Mirien
  • 1
  • 2
0

I read on OpenSSL site that some versions are not yet supported. There is also no back compatibility or no more compatibility between php-5.6 or some CURL versions. I had recompiled a different version of openssl, that is their LTS program. All work flawless

Pedram
  • 53
  • 6