PHP - SSL certificate error: unable to get local issuer certificate

前端 未结 16 2799
时光取名叫无心
时光取名叫无心 2020-11-21 07:49

I\'m running PHP Version 5.6.3 as part of XAMPP on Windows 7.

When I try to use the Mandrill API, I\'m getting the following error:

Uncaught e

相关标签:
16条回答
  • 2020-11-21 08:12

    I had the same issue during building my app in AppVeyor.

    • Download https://curl.haxx.se/ca/cacert.pem to c:\php
    • Enable openssl echo extension=php_openssl.dll >> c:\php\php.ini
    • Locate certificateecho curl.cainfo=c:\php\cacert.pem >> c:\php\php.ini
    0 讨论(0)
  • 2020-11-21 08:18

    Thanks @Mladen Janjetovic,

    Your suggestion worked for me in mac with ampps installed.

    Copied: http://curl.haxx.se/ca/cacert.pem

    To: /Applications/AMPPS/extra/etc/openssl/certs/cacert.pem

    And updated php.ini with that path and restarted Apache:

    [curl]
    ; A default value for the CURLOPT_CAINFO option. This is required to be an
    ; absolute path.
    curl.cainfo="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"
    openssl.cafile="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"
    

    And applied same setting in windows AMPPS installation and it worked perfectly in it too.

    [curl]
    ; A default value for the CURLOPT_CAINFO option. This is required to be an
    ; absolute path.
    curl.cainfo="C:/Ampps/php/extras/ssl/cacert.pem"
    openssl.cafile="C:/Ampps/php/extras/ssl/cacert.pem"
    

    : Same for wamp.

    [curl]
    ; A default value for the CURLOPT_CAINFO option. This is required to be an
    ; absolute path.
    curl.cainfo="C:/wamp/bin/php/php5.6.16/extras/ssl/cacert.pem"
    openssl.cafile="C:/wamp/bin/php/php5.6.16/extras/ssl/cacert.pem"
    

    If you are looking for generating new SSL certificate using SAN for localhost, steps on this post worked for me on Centos 7 / Vagrant / Chrome Browser.

    0 讨论(0)
  • 2020-11-21 08:19

    I found new Solution without any required certification to call curl only add two line code.

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    0 讨论(0)
  • 2020-11-21 08:21

    elaborating on the above answers for server deployment.

    $hostname = gethostname();
    if($hostname=="mydevpc")
    {
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    }
    

    should do the trick for development environment without compromising the server when deployed.

    0 讨论(0)
提交回复
热议问题