I
I
Igor Belov2014-03-09 17:12:43
PHP
Igor Belov, 2014-03-09 17:12:43

Why does PHP cURL throw an error Problem with the SSL CA cert?

Please tell me, cURL in PHP, when trying to connect to a host via https, persistently gives an error "Problem with the SSL CA cert (path? access rights?)". The certificate at the address I am accessing is unverified, but I disable the need to verify the certificate in the options.
Here is the code:

if($cu=curl_init('https://example.com')) {
    curl_setopt($cu, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($cu, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($cu, CURLOPT_SSLVERSION, 3);
    curl_setopt($cu, CURLOPT_TIMEOUT, 30);
    $res = curl_exec($cu);
    curl_close($cu);
}

Instead of https://example.com I specify my host. On http everything works, but on https it gives this error.
Tell me, please, in which direction to drip.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
scopenco, 2014-03-13
@ibelov

For those who use nginx+php-fpm scheme in chroot, copy
/usr/lib64/libnsspem.so
/usr/lib64/libsoftokn3.so
to chroot/lib64 directory.

S
Sergey Savostin, 2014-03-09
@savostin

try:
yum reinstall openssl ca-certificates -y

S
Sergey Savostin, 2014-03-09
@savostin

There is also an option like this:

wget http://curl.haxx.se/ca/cacert.pem
cp cacert.pem /usr/local/etc/cacert.pem
echo "curl.cainfo = \"/usr/local/etc/cacert.pem\"" >> /etc/php.ini

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question