0

Installed Imagick in Xampp using this link. It was working properly but stopped working all of sudden.

Only thing I did in between, tried to configure gmail stmp setting in zend 3. Though I am not sure but it stopped working after that.

This is the error

Fatal error: Uncaught ImagickException: Imagick::__construct(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\xampp\htdocs\restau\restau\public\image.php:55 Stack trace: #0 C:\xampp\htdocs\restau\restau\public\image.php(55): Imagick->__construct('https://storage...') #1 {main} Next ImagickException: Failed to read the file in C:\xampp\htdocs\restau\restau\public\image.php:55 Stack trace: #0 C:\xampp\htdocs\restau\restau\public\image.php(55): Imagick->__construct('https://storage...') #1 {main} thrown in C:\xampp\htdocs\restau\restau\public\image.php on line 55

line of having error

Edit 1

Followed this link and changed

curl.cainfo ="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"

openssl.cafile="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"

this is the error I am getting now

Fatal error: Uncaught ImagickException: Failed to read the file in C:\xampp\htdocs\restau\restau\public\image.php:55 Stack trace: #0 C:\xampp\htdocs\restau\restau\public\image.php(55): Imagick->__construct('https://storage...') #1 {main} thrown in C:\xampp\htdocs\restau\restau\public\image.php on line 55

Below is the code in which image is not getting loaded, this was working properly until few days ago.

<img src="/image.php?filename=https://storage.googleapis.com/xxxxxx/uploads_56ea606ea4685.jpg&amp;width=380&amp;height=255" alt="">

Thanks in advance!!

Arvind Jha
  • 62
  • 1
  • 10
  • That does not look like a problem of Imagick, but of OpenSSL. Obviously, you are trying to connect to a URL with a non-verifable certificate. Have a look at https://stackoverflow.com/questions/6400300/https-and-ssl3-get-server-certificatecertificate-verify-failed-ca-is-ok – Nico Haase Mar 08 '18 at 14:29
  • thanks for replying. I have updated my question. – Arvind Jha Mar 09 '18 at 08:03
  • Can you try this using `file_get_contents`? Also, I don't think the Google servers use CACert – Nico Haase Mar 09 '18 at 08:05

1 Answers1

0

This is how I fixed this problem.

I replaced this part of code

if(filter_var($imagePath, FILTER_VALIDATE_URL)) {
    $imagick = new Imagick($imagePath);
} else {
    $imagick = new Imagick(getcwd().$imagePath);
}

with this

if(filter_var($imagePath, FILTER_VALIDATE_URL)) {
  $tempFile = 'temp/file-'.uniqid().'.jpg';
  copy($imagePath, $tempFile);
  $imagick = new Imagick(getcwd().'/'.$tempFile);
  unlink(getcwd().'/'.$tempFile);
} else {
  $imagick = new Imagick(getcwd().$imagePath);
}
Arvind Jha
  • 62
  • 1
  • 10