douqiao1997 2013-06-21 08:38
浏览 78
已采纳

迁移到新服务器后,cURL出现SSL问题

I'm using cURL to send some data using CURLOPT_POST. Same code was working fine before but after moving to a new server cURL is not working anymore via https. The guys from the other site (domain.com) sent me the log files and nothing was received by them. Then I tried to get an error with curl_error() and I was faced with a SSL problem but don't know how to fix it.

Code:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,'https://track.domain.com/api.php'); 
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); 
curl_exec($ch);
$error = curl_error($ch); 
curl_close($ch);

The error is:

SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I searched for this on Google but couldn't understand what the problem is.

Do I need SSL certificate for our domain? I'm not sure if there was SSL in the old server. Is you can see from the code, I don't need return. So, should I have SSL, too, in this case?

Do I need domain.com's certificate?

Do I need contacting the hosting company for recompiling cURL with SSL support?

Any ideas?


Note: I don't want a workaround by setting CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to false.


curl_version():

Array
(
    [version_number] => 464896
    [age] => 3
    [features] => 34333
    [ssl_version_number] => 0
    [version] => 7.24.0
    [host] => i686-pc-linux-gnu
    [ssl_version] => OpenSSL/0.9.8b
    [libz_version] => 1.2.3
    [protocols] => Array
        (
            [0] => dict
            [1] => file
            [2] => ftp
            [3] => ftps
            [4] => gopher
            [5] => http
            [6] => https
            [7] => imap
            [8] => imaps
            [9] => pop3
            [10] => pop3s
            [11] => rtsp
            [12] => smtp
            [13] => smtps
            [14] => telnet
            [15] => tftp
        )

)
  • 写回答

1条回答 默认 最新

  • dongyakui8675 2013-06-21 08:51
    关注

    downloaded Mozilla's bundle file, named it mozilla.pem

    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true); 
    curl_setopt($ch,CURLOPT_CAINFO,'mozilla.pem'); 
    

    The issue is your CA (Certificate Authority) list doesn't have the issuer of the remote site certificate. This method will not fix if your trying to connect to a server who has a self singed certificate.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块