barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.63k stars 291 forks source link

SSL resources not loading #217

Closed khanof89 closed 6 years ago

khanof89 commented 7 years ago

I am trying to load a view which generates charts and bars using google charts library, because the chart library is hosted on google server with an SSL, I get the following error :

(1/1) RuntimeException

The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% QSslSocket: cannot resolve CRYPTO_num_locks QSslSocket: cannot resolve CRYPTO_set_id_callback QSslSocket: cannot resolve CRYPTO_set_locking_callback QSslSocket: cannot resolve sk_free QSslSocket: cannot resolve sk_num QSslSocket: cannot resolve sk_pop_free QSslSocket: cannot resolve sk_value QSslSocket: cannot resolve SSL_library_init QSslSocket: cannot resolve SSL_load_error_strings QSslSocket: cannot resolve SSLv3_client_method QSslSocket: cannot resolve SSLv23_client_method QSslSocket: cannot resolve SSLv3_server_method QSslSocket: cannot resolve SSLv23_server_method QSslSocket: cannot resolve X509_STORE_CTX_get_chain QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf QSslSocket: cannot resolve SSLeay QSslSocket: cannot call unresolved function CRYPTO_num_locks QSslSocket: cannot call unresolved function CRYPTO_set_id_callback QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback QSslSocket: cannot call unresolved function SSL_library_init QSslSocket: cannot call unresolved function SSLv23_client_method QSslSocket: cannot call unresolved function sk_num [===============> ] 25% [=====================> ] 36% [=========================> ] 43% QSslSocket: cannot call unresolved function SSLv23_client_method QSslSocket: cannot call unresolved function SSL_library_init Warning: Failed to load https://www.gstatic.com/charts/45.2/loader.js (ignore) [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) Printing pages (6/6) [> ] Preparing [===================> ] Page 1 of 3 [=======================================> ] Page 2 of 3 [============================================================] Page 3 of 3 Done Exit with code 1 due to network error: ContentNotFoundError QSslSocket: cannot call unresolved function CRYPTO_num_locks QSslSocket: cannot call unresolved function CRYPTO_set_id_callback QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback " stdout: "" command: /usr/local/bin/wkhtmltopdf-amd64 --lowquality '/tmp/knp_snappy59719aad573823.86128540.html' '/tmp/knp_snappy59719aad573c74.43593591.pdf'.

Just so you know, following is my code which I have tried

//return view('pdf.reports', compact('merged', 'request', 'marketplaces', 'brands', 'title', 'type'));
        //$pdf = App::make('snappy.pdf');
        return SnappyPdf::loadView('pdf.reports', ['merged' => $merged, 'request' => $request, 'marketplaces' => $marketplaces, 'brands' => $brands, 'title' => $title, 'type' => $title])->inline('page.pdf');
        //$pdf = SnappyPdf::loadView('pdf.reports', compact('merged', 'request', 'marketplaces', 'brands', 'title', 'type'));
        //return $pdf->download();

and the error is because of SSL is my wild guess, I just tried to load a simple view which also didnt work

siddharthghedia commented 7 years ago

@khanof89 I'm facing the same issue, please let me know if you find any solution for this.

khanof89 commented 7 years ago

@siddharthghedia no solutions so far, google charts doesn't work locally and it is their TOS also that you cannot use it locally, and wkhtmltopdf doesn't handle ssl properly

siddharthghedia commented 7 years ago

@khanof89 I guess problem is not with SSL, I just tried removing the SSL, and is still showing the same error :(

khanof89 commented 7 years ago

@siddharthghedia een if you remove https from the first url i.e https://www.gstatic.com/charts/45.2/loader.js the other scripts called by loader.js are still on ssl, gogole charts doesn't work without ssl

siddharthghedia commented 7 years ago

@khanof89 ssl is the problem yeah :D :D , was working when removed ssl, when added back, its not working :(

nonsocode commented 6 years ago

I found a solution that works. checkout @Kaicastledine's solution on this thread

Summary

Downgrade libssl apt install libssl-dev=1.0.2g-1ubuntu4.8

Lock it from future upgrades apt-mark hold libssl-dev

Sunyuzhu commented 6 years ago

@nonsocode Thanks very much!!!

roni-estein commented 6 years ago

The downgrade libs change, right now it's 4.10 not 4.8, look here for the current version for you. https://packages.ubuntu.com/xenial/libssl1.0.0

esobolev commented 6 years ago

For Ubuntu 17.10:

apt install libssl-dev=1.0.2g-1ubuntu13.3

leemarkwood commented 6 years ago

On Ubuntu 17.10 I used the following package to fix this issue.

apt-get install libssl1.0-dev

bluemountainteam commented 6 years ago

For Ubuntu 18.04, any idea ? :-)

vnetmx commented 6 years ago

14.04 = apt install libssl-dev=1.0.1f-1ubuntu2.25 (Tested and worked) 18.04 = apt install libssl-dev=1.0.2n-1ubuntu5 (Not tested) @bluemountainteam

icaroscherma commented 6 years ago

@vnetmx Tried in Ubuntu 18.04 Linux AMI (AWS)

sudo apt install libssl-dev=1.0.2n-1ubuntu5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '1.0.2n-1ubuntu5' for 'libssl-dev' was not found

But I tried to just sudo apt install libssl1.0-dev and I got it working, but it uninstalled php7.2-dev. =(

vnetmx commented 6 years ago

@icaroscherma

Try this: sudo apt install libssl1.0-dev=1.0.2n-1ubuntu5

FelipeeDev commented 6 years ago

@vnetmx

sudo apt install libssl1.0-dev=1.0.2n-1ubuntu5

Works on Ubuntu 18.04. Thx a lot!

barryvdh commented 6 years ago

Yeah but I'm not sure that is the best way, as you're actually downgrading lib ssl, right?

bvisonl commented 6 years ago

@icaroscherma Thanks! sudo apt install libssl1.0-dev worked like a charm!

vnetmx commented 6 years ago

@barryvdh I think we are only installing Development Files, not downgrading lib. But this is only a workaround, maybe we need a fix to work with newer versions.

nam-co commented 6 years ago

Hi @barryvdh , I understand its not a problem of you're package, but a problem with new versions of Ubuntu, anyway as you can see here https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001#issuecomment-396815585 the issue was resolved (much better than downgrading) , but the composer package maintainer hasn't updated to the new version (0.12.5), is there any way to use another package or fork?

Appreciate any help

barryvdh commented 6 years ago

See https://github.com/h4cc/wkhtmltopdf-amd64/issues/31 You are free to fork or install it yourself, I don't maintain wkhtmltopdf of the composer binaries.

But glad it's solved with the latest version :)

mariapaulinar commented 5 years ago

Ubuntu 18.04.1:

sudo apt-get install libssl1.0-dev

https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001

Brokan commented 5 years ago

Upgdaring wkhtmltopdf to 0.12.5 solve SSL problem.

AugmentBLU commented 5 years ago

I have the same issue. Using Ubuntu 18.04. I installed wkhtmltopdf to 0.12.5 and still have the same issues.

What is a safe way to fix this, without downgrading SSL libs?

ajcastro commented 4 years ago

In my case I fixed it by not using https when rendering in snappy... like

{{ request()->boolean('use_snappy') ? 'http' : 'https' }}://some-url.com/assets/style.css
dwijonarko commented 4 years ago

update wkhtmltopdf to version 0.12.6 fixed this error

casperwitting commented 3 years ago

update wkhtmltopdf to version 0.12.6 fixed this error

This version doesn't exist? 0.12.4 is the latest -> https://github.com/h4cc/wkhtmltopdf-amd64/tags

barryvdh commented 3 years ago

Not as composer package; https://github.com/h4cc/wkhtmltopdf-amd64/pull/44 I suggest you download the binary directly: https://wkhtmltopdf.org/downloads.html

barryvdh commented 3 years ago

Forge recipe to install:

echo ">> Installing WkhtmltoPDF 0.12.6"
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get --yes -f install
sudo cp /usr/local/bin/wkhtmlto* /usr/bin/
casperwitting commented 3 years ago

Thanks @barryvdh, this worked for me! I added wkhtmltopdf as dependency to my docker configuration and pointed theWKHTMLTOPDF_PATH value to it.

ismailansari commented 3 years ago

Well I found a hack for this in Laravel I did like the following and it worked <img class="w100" editable="" mc:edit="mm-92" label="image" src="data:image/jpeg;base64,{{ \base64_encode(@file_get_contents($booking_detail['hotel_picture'])) }}">

wisquimas commented 3 years ago

I have the same issue. Using Ubuntu 18.04. I installed wkhtmltopdf to 0.12.5 and still have the same issues.

What is a safe way to fix this, without downgrading SSL libs?

Have you been able to solve the problem?

For me @barryvdh solutions is not working. I need wkhtmltopdf-amd64 binary solution without downgrade my OS.

itzmj-23 commented 2 years ago

My fix:

Installed wkhtmltopdf on my server sudo apt update sudo apt install wkhtmltopdf

After successful installation, I find the wkhtmltopdf and create a symlink find / -name wkhtmltopdf ln -s /usr/bin/wkhtmltopdf /usr/local/bin/whtmltopdf-amd64

For me, this is the fix for my encountered errors such as 'ssl resources not loading, error 127, libssl error, and many more' I think it is case to case basis depends on the environment and versions of platforms. Thanks.

My Platform Details:

stuartcusackie commented 1 year ago

I got stuck with Ubuntu 22.04, so here's the a recipe that works for that:

echo ">> Installing WkhtmltoPDF 0.12.6.1-2"
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt-get --yes -f install
sudo cp /usr/local/bin/wkhtmlto* /usr/bin/