简体   繁体   English

具有SSL证书的php cUrl POST以错误500结尾

[英]php cUrl POST with SSL certificate end with an error 500

I've got a PHP cUrl session that works well with HTTP URLs but ends with an error 500 with https... 我有一个PHP cUrl会话,可以很好地与HTTP URL一起使用,但是以HTTP错误500结束。

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: 这是$ curl_info的print_r:

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!! 非常感谢您的帮助!!

A 500 error is a generic error on the remote server, so probably nothing much that you can debug. 500错误是远程服务器上的一般错误,因此可能没有什么可以调试的。 You may need to contact the devs of the remote server to find out why their HTTPS site is giving a 500 error. 您可能需要联系远程服务器的开发人员,以了解为什么他们的HTTPS站点出现500错误。 – 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! 感谢您指出正确的方向!

I read on OpenSSL site that some versions are not yet supported. 我在OpenSSL网站上看到某些版本尚不支持。 There is also no back compatibility or no more compatibility between php-5.6 or some CURL versions. php-5.6或某些CURL版本之间也没有向后兼容性,也没有更多兼容性。 I had recompiled a different version of openssl, that is their LTS program. 我重新编译了opensl的​​另一个版本,即他们的LTS程序。 All work flawless 一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM