Xhtml2PDF, Web pages with Images, ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
See original GitHub issueI have a script which parses the content of the website and converts it to PDF files. The website was not using https but recently switched to it. After that my script stopped working as expected for pages which contain links to images.
The error goes from this line:
pisaStatus = pisa.CreatePDF(
sourceHtml, # the HTML to convert
dest=resultFile) # file handle to recieve result
For any page which has link to image I get following error:
File "default_old.py", line 164, in convert_html_to_pdf
dest=resultFile) # file handle to recieve result
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/document.py", line 97, in pisaDocument
encoding, context=context, xml_output=xml_output)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/document.py", line 59, in pisaStory
pisaParser(src, context, default_css, xhtml, encoding, xml_output)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 708, in pisaParser
pisaLoop(document, context)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 648, in pisaLoop
pisaLoop(node, context, path, **kw)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 593, in pisaLoop
pisaLoop(nnode, context, path, **kw)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 593, in pisaLoop
pisaLoop(nnode, context, path, **kw)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 477, in pisaLoop
attr = pisaGetAttributes(context, node.tagName, node.attributes)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/parser.py", line 117, in pisaGetAttributes
nv = c.getFile(nv)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/context.py", line 848, in getFile
return getFile(name, relative or self.pathDirectory)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/util.py", line 673, in getFile
file = pisaFileObject(*a, **kw)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/site-packages/xhtml2pdf/util.py", line 581, in __init__
conn.request("GET", path)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 1057, in request
self._send_request(method, url, body, headers)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 1097, in _send_request
self.endheaders(body)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 897, in _send_output
self.send(msg)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 859, in send
self.connect()
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/httplib.py", line 1278, in connect
server_hostname=server_hostname)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/ssl.py", line 352, in wrap_socket
_context=self)
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/ssl.py", line 579, in __init__
self.do_handshake()
File "/home/alexander/.pyenv/versions/2.7.11/lib/python2.7/ssl.py", line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
How can I solve it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
Developers - Xhtml2PDF, Web pages with Images, ssl.SSLError ...
Xhtml2PDF, Web pages with Images, ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) ... I have a script which parses the ...
Read more >[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed ...
Open a terminal and take a look at: /Applications/Python 3.6/Install Certificates.command. Python 3.6 on MacOS uses an embedded version of OpenSSL, ...
Read more >How to fix Python SSL CERTIFICATE_VERIFY_FAILED
how to fix Python SSL errors when downloading web pages using the https protocol ... [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590).
Read more >Https option — xhtml2pdf 0.2.7 documentation
xhtml2pdf --http_nosslcheck https://domain yourfile.pdf. the --http_nosslcheck is a special argument that help to disable the ssl certificate check.
Read more >[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed ...
TL;DR. The remote website seems to be the problem, not Python. There is likely no fix for this other than to fix the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, Basically you need to set httpConfig before call pisa.CreatePDF For example:
other way is setting as a dict
Great,
It’s helps a lot if you could write some documentation about how make it work (based in this issue answers) so I could include in documentation and merge in master faster.