Images with https in mpdf

2019-07-12 04:24发布

问题:

I am using MPDF to generate a pdf with images. With http:// all works fine, but after changing my whole site to https:// I only get red crosses where the images should appear.

If I watch the generated file as html version, the images are all there, with https://, but in the generated PDF they are just not shown.

Any hint?

UPDATE: Error was because of CURL ("SSL certificate problem: unable to get local issuer certificate")

It was resolved by adding curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); to mpdf.php

Answer was found here: curl: (60) SSL certificate : unable to get local issuer certificate

Dirty Way: cURL PHP RESTful service always returning FALSE

回答1:

For anyone coming here from Google - there is now a better solution. mPDF now supports setting curlAllowUnsafeSslRequests.

$mdf = new Mpdf(<your configuration>);
$mpdf->curlAllowUnsafeSslRequests = true;

This will set the CURL parameters properly for you without having to modify mPDF. Obviously, use only in appropriate situations, as this disables SSL all verification protections.



回答2:

To resolve this issue you need to remove the protocol from URL for this I have created a plugin please install it and activate.

Here is the plugin link:- https://wordpress.org/plugins/vg-protocol-removed-not-secure-connection/



回答3:

If you have a root cert, it's preferable to provide it using CURLOPT_CAINFO or CURLOPT_CAPATH than to bypass validation altogether.

It is a shame mPDF isn't designed better so you could avoid modifying the library code directly.