迁移到新服务器后cURL的SSL问题


SSL issue with cURL after moving to a new server

我使用cURL使用CURLOPT_POST发送一些数据。同样的代码之前工作得很好,但在移动到一个新的服务器后,cURL不再通过https工作。另一个网站(domain.com)的家伙给我发了日志文件,他们什么也没有收到。然后我试图得到一个错误与curl_error()和我面临的SSL问题,但不知道如何修复它。

代码:

$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);

错误是:

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

我在谷歌上搜索了这个,但不明白是什么问题。

我们的域名需要SSL证书吗?我不确定旧服务器中是否有SSL。就是你可以从代码中看到,我不需要返回。那么,在这种情况下,我还应该使用SSL吗?

我需要domain.com的证书吗?

我需要联系托管公司重新编译cURL与SSL支持?

任何想法?


注意:我不想通过将CURLOPT_SSL_VERIFYPEERCURLOPT_SSL_VERIFYHOST设置为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
        )
)

下载Mozilla的bundle文件,命名为mozilla.pem

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

问题是您的CA(证书颁发机构)列表没有远程站点证书的颁发者。如果您试图连接到具有自签名证书的服务器,则此方法将无法修复。