Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wicked_pdf due to wkhtmltopdf not finding OpenSSL 1.1 despite installing over OpenSSL 3 #1114

Closed
AndyObtiva opened this issue Apr 25, 2024 · 7 comments

Comments

@AndyObtiva
Copy link

AndyObtiva commented Apr 25, 2024

Issue description

After we upgraded our Rails 7 app to Ruby 3.1 and OpenSSL 3 in our build server, we are having an issue when using our Rails app to generate a PDF where wicked_pdf somehow fails due to expecting OpenSSL 1.1.

RuntimeError Failed to execute:
["/usr/bin/wkhtmltopdf", "--orientation", "Portrait", "--page-size", "Letter", "--margin-top", "45", "--header-html", "file:////tmp/wicked_header_pdf20240416-1-cz41ln.html", "file:////tmp/wicked_pdf20240416-1-g5no29.html", "/tmp/wicked_pdf_generated_file20240416-1-8tyx4w.pdf"]
Error: PDF could not be generated!
 Command Error: pid 49 exit 127
Error loading shared library libssl.so.1.1: No such file or directory (needed by /usr/bin/wkhtmltopdf)
Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /usr/bin/wkhtmltopdf)

We are installing wkhtmltopdf as a prerequisite from a Docker image (madnight/docker-alpine-wkhtmltopdf).

Expected or desired behavior

We expect wicked_pdf to work normally with our Docker image that has OpenSSL3 and Ruby 3.1 instead of OpenSSL 1.1 and Ruby 2.7

System specifications

wicked_pdf gem version (output of cat Gemfile.lock | grep wicked_pdf):

    wicked_pdf (2.7.0)
  wicked_pdf (~> 2.6, >= 2.6.3)

wkhtmltopdf version (output of wkhtmltopdf --version):

Version 0.12.5, which comes with the Docker image madnight/docker-alpine-wkhtmltopdf

whtmltopdf provider gem and version if one is used:

We don't use wkhtmltopdf-binary.

platform/distribution and version (e.g. Windows 10 / Ubuntu 16.04 / Heroku cedar):

Alpine Linux: ruby:3.1-alpine

--

We just tried relying on wkhtmltopdf-binary instead of the wkhtmltopdf library in the Docker image to fix the issue and our web server kept crashing upon accessing PDF URLs that use wicked_pdf.

Is there a way to make wicked_pdf work with OpenSSL3 using wkhtmltopdf? If not, can wicked_pdf work with an alternative low-level PDF library that is compatible with OpenSSL 3, like puppeteer perhaps?

@aarestad
Copy link

aarestad commented May 7, 2024

We are hitting this too, using the ruby:3.3.1 Docker image (aka 3.3.1-bookworm). I found a related issue on StackOverflow and think I'll try the recommended path of grabbing libssl manually.

@kimesf
Copy link

kimesf commented May 7, 2024

You have to use the binary built against Debian bookworm. It works with OpenSSL3.

wkhtmltopdf_binary gem still don't support it (see zakird/wkhtmltopdf_binary_gem#162).

The package can be downloaded from Github (see wkhtmltopdf/packaging#155).

Get the binary from the package and setup the project to use it with something like this:

# config/initializers/wicked_pdf.rb
WickedPdf.config = {
  exe_path: Rails.root.join("bin", "wkhtmltopdf-amd64").to_s, # or wherever you put it
  enable_local_file_access: true
}

@patricksimpson
Copy link

patricksimpson commented May 8, 2024

Hit this issue as well. We we're able to install the libssl manually and get past it.

RUN wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb

Edit: I don't think this workaround is ideal.

@patricksimpson
Copy link

Also changing our base to FROM ruby:3.3.1-bullseye works for us.

@kimesf
Copy link

kimesf commented May 14, 2024

wkhtmltopdf_binary is now supporting Debian 12 on 0.12.6.7 🎉

I think this can be closed btw

@unixmonkey
Copy link
Collaborator

@AndyObtiva Let me know if this solves your problem or not please. Feel free to reopen if it doesn't. Thank you.

@AndyObtiva
Copy link
Author

AndyObtiva commented May 16, 2024

My OS is Alpine Linux (ruby:3.1-alpine as mentioned in the issue description body), not Debian 12. But, we stumbled upon a workaround that is good enough for now. If we decide to do an upgrade in the future, I will let you know if wkhtmltopdf_binary would not work.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants