restezconnectes / send-pdf-for-contact-form-7

Send the PDF for Contact Form 7 plugin will allow you to recover the data yourself via your form to insert them into a PDF built and prepared by you.
https://restezconnectes.fr/tutoriel-wordpress-lextension-send-pdf-for-contact-form-7/
GNU General Public License v3.0
15 stars 17 forks source link

logo and signature image not displaying due to https issue #27

Closed ErnstDinkelmann closed 2 years ago

ErnstDinkelmann commented 2 years ago

Hi there

Using the Contact Form 7 Signature Addon plugin, together with this plugin.

My domain is https, with valid certificates. Hosted on aws, ec2, bitnami for wordpress - this may be relevant as it's possible that it's a setup issue.

Two problems experienced, indicating some underlying authentication problem. 1) In settings, the selected logo file, populates as https reference. But on the "Preview your PDF" preview, it does not display. It also does not display in the actual pdf sent via email. Only displays a small red cross. When manually changing the path text from https to http, the logo image now displays in the "Preview your PDF" preview and on the actual sent PDF. Interestingly, the https logo does display on the standard preview that is shown directly in settings - the one with "Lorem ipsum.."

2) The <img src="[your-signature]" height="200" /> image is not displaying on the "Preview your PDF" preview. And also not on the actual sent PDF. Again, only red cross shown. Suspect the comes down to the same problem as the above on - i.e. I think if I edited the /classes/send-pdf.php to replace https with http for img paths, it would display. This is obviously not desirable due to overwrites.

I'm not really exactly sure what to ask. Any ideas on what might be going on here - ie this plugin not allowed to properly read/access files with https urls/paths?

ErnstDinkelmann commented 2 years ago

I've just confirmed that if I add, just after "//shortcodes ?" section in /classes/send-pdf.php (about line 1010): $text = str_ireplace( 'https', 'http', $text ); it then correctly populates the signature.

Therefore, I now have a "hack" for both the logo image and signature, but it does not address the underlying problem of being able to retrieve https url images.

ErnstDinkelmann commented 2 years ago

I've also stumbled upon something that may be the cause of this. It seems we are missing some ssl intermediate/chain certificate(s): https://www.sslshopper.com/ssl-checker.html#hostname=www.crywolf.co.za e.g. curl https://www.crywolf.co.za fails, with "curl: (60) SSL certificate problem: unable to get local issuer certificate"

Could this be the cause of the problem?

ErnstDinkelmann commented 2 years ago

Solved!

Problem was a missing ca-bundle file, received now from the previous host.

Copied the ca-bundle file, requested from previous host, into the /opt/bitnami/apache/conf/bitnami/certs/ directory. Then ensured, /opt/bitnami/apache/conf/vhosts/wordpress-https-vhost.conf, and /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf, contained references to all three certificate related files:

SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"
SSLCertificateChainFile "/opt/bitnami/apache/conf/bitnami/certs/ca-bundle"

in the VirtualHost directive.

I then, from the plugin php removed the code which I added as a work-around which forced https to http references, to test. And I'm happy to report, it works! Ie, logo and signature is now displaying with https references, without any work-arounds needed.

This means the issue is perfectly resolved.

For anyone else struggling with logo, images and signature on a https host, but which works with http references when tested, should definitely check that your https/ssl setup is really complete. Remember, even without the ca-bundle, browsers did not report and issue with our https/ssl setup. You have to test it with a tool like: https://www.sslshopper.com/ssl-checker.html

Cheers

restezconnectes commented 2 years ago

Hi!

Thanks a lot for your expertise!