Error de certificado PHP-SSL: no se puede obtener el certificado del emisor local


Estoy ejecutando la versión 5.6.3 de PHP como parte de XAMPP en Windows 7.

Cuando intento usar la API Mandrill, recibo el siguiente error:

Excepción no capturada 'Mandrill_HttpError' con mensaje 'llamada de API a mensajes / enviar-plantilla falló: problema del certificado SSL: no se puede obtener el certificado del emisor local'

Ya he probado todo lo que he leído en StackOverflow, incluyendo la adición de lo siguiente a php.archivo ini:

curl.cainfo = "C:\xampp\php\cacert.pem"

Y por supuesto descargado a esa ubicación es el cacert.archivo pem de http://curl.haxx.se/docs/caextract.html

Pero después de todo eso, se reinició el servidor XAMPP y Apache pero aún así se obtiene el mismo error.

Realmente no sé qué más probar.

¿Puede alguien aconsejarme sobre qué más puedo probar?

Author: abraham, 2015-03-04

11 answers

Finalmente conseguí que esto funcionara!

  1. Descargue el paquete de certificados .

  2. Ponlo en alguna parte. En mi caso, ese era el directorio c:\wamp\ (si estás usando Wamp 64 bit entonces es c:\wamp64\).

  3. Habilitar mod_ssl en Apache y php_openssl.dll en php.ini (descomentarlos eliminando ; al principio). Pero ten cuidado, mi problema era que tenía dos archivos php.ini y necesito hacer esto en ambos. Uno es el que obtienes de tu barra de tareas WAMP icono, y otro es, en mi caso, en C:\wamp\bin\php\php5.5.12\

  4. Agregue estas líneas a su certificado en ambos archivos php.ini:

    curl.cainfo="C:/wamp/cacert.pem"
    openssl.cafile="C:/wamp/cacert.pem"
    
  5. Reinicie los servicios Wamp.

 229
Author: Mladen Janjetovic,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-22 09:02:30

Descargo de responsabilidad: Este código hace que su servidor sea inseguro.

Tuve el mismo problema en Mandrill.archivo php después de la línea número 65 donde dice this this - > ch = curl_init ();

Añadir las dos líneas siguientes:

curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);

Esto resolvió mi problema y también envió correo electrónico usando localhost, pero sugiero NO usarlo en la versión en vivo en vivo. En su servidor en vivo, el código debería funcionar sin este código.

 83
Author: Shehzad Nizamani,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-15 08:55:32

Gracias @Mladen Janjetovic,

Su sugerencia funcionó para mí en mac con ampps instalado.

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

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

Y actualizado php.ini con esa ruta y reiniciado 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"

Y aplicó la misma configuración en la instalación de Windows AMPPS y funcionó perfectamente en ella también.

[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"

: Lo mismo para 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"

Si está buscando generar un nuevo certificado SSL usando SAN para localhost, steps on este post funcionó para mí en Centos 7 / Vagrant / Chrome Browser.

 35
Author: Damodar Bashyal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-06 23:30:39

Cuando vea el http://curl.haxx.se/docs/caextract.html página, usted notará en letras grandes una sección llamada:

RSA-1024 removed

Léalo y luego descargue la versión de los certificados que incluye los certificados 'RSA-1024'. https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

Esos funcionarán con Mandrill.

Deshabilitar SSL es una mala idea.

 17
Author: Arturo Alvarado,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-09 21:36:15

Los pasos anteriores, aunque útiles, no funcionaron para mí en Windows 8. No conozco la relación, pero los siguientes pasos funcionaron. Básicamente un cambio en el cacert.archivo pem. Espero que esto ayude a alguien.

  • Descargar cacert.archivo pem desde aquí: http://curl.haxx.se/docs/caextract.html
  • Guarde el archivo en su carpeta de instalación de PHP. (eg: Si usa xampp – guárdelo en c:\Installation_Dir\xampp\php\cacert.pem).
  • Abra su php.archivo ini y añadir estos líneas:
  • curl.cainfo="C:\Installation_Dir\xampp\php\cacert.pem" openssl.cafile="C:\Installation_Dir\xampp\php\cacert.pem "
  • Reinicie su servidor Apache y eso debería arreglarlo (Simplemente deténgase e inicie el servicios según sea necesario).
 9
Author: HopeKing,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-25 09:55:05

Encontré una nueva solución sin ninguna certificación requerida para llamar a curl solo agregue el código de dos líneas.

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 7
Author: Manish sharma,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-20 06:33:41

Desarrollando las respuestas anteriores para el despliegue del servidor.

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

Debería hacer el truco para el entorno de desarrollo sin comprometer el servidor cuando se implementa.

 2
Author: Noel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-08 02:29:23

Si no tiene acceso a php.ini, añadiendo este código (después de tu $ch = curl_init(); línea) funciona para mí:

$certificate_location = "C:\Program Files (x86)\EasyPHP-Devserver-16.1\ca-bundle.crt"; // modify this line accordingly (may need to be absolute)
curl_setopt($ch, CURLOPT_CAINFO, $certificate_location);
curl_setopt($ch, CURLOPT_CAPATH, $certificate_location);

Entonces, solo tendrá que descargar ca-bundle.crt y guárdelo en la ubicación especificada en $certificate_location.

 2
Author: ban-geoengineering,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-25 19:54:13

Tuve el mismo problema durante la construcción de mi aplicación en AppVeyor.

  • Descargar https://curl.haxx.se/ca/cacert.pem a c:\php
  • Habilitar openssl echo extension=php_openssl.dll >> c:\php\php.ini
  • Localizar certificado echo curl.cainfo=c:\php\cacert.pem >> c:\php\php.ini
 0
Author: Facedown,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-11 12:03:53

Si ninguna de las soluciones anteriores funciona para usted, intente actualizar su instalación de XAMPP a una versión más reciente.

Estaba ejecutando XAMPP con php 5.5.11, el mismo código exacto no funcionaba, actualicé a XAMPP con php 5.6.28 y las soluciones anteriores funcionaron.

Además, solo actualizar PHP no funcionó tampoco parece una combinación de configuraciones de apache y php en esa versión de XAMPP.

Espero que ayude a alguien.

 0
Author: ccrez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-06 18:05:00

Si sabe, desde xampp ya suministra la fuente, vea y haga esto tutorial

 0
Author: Eka putra,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-11 17:29:42