Using Urlopen or urlretreive from urllib.request fails
This could be related to this bug: #109241.
Steps to Reproduce:
1. Get the spreadsheet file from #109241
Error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:719)>
User Profile Reset: No
This has been a problem on Linux for some time. I think #109241 was classified as Windows only by mistake.
Created attachment 151055 [details]
Example script to demo error
The download macro reproduces the error.
I don't think this a LibreOffice problem but a request problem.
Please check https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error
Closing as RESOLVED NOTABUG. Put it back to UNCONFIRMED if you disagree
Thank you. Your effort is appreciated.
But I disagree :-)
For two reasons:
A very similar problem on Windows was fixed some time ago.
The article on Stackoverflow that you refer to is Python 2.7 and a completely different library (Urllib2).
I will add Michael Stahl as he fixed #109241.
@Michael: If you agree with Xisco I'll accept the case to be closed.
bug 109241 is about urllib not supporting https protocol at all, while if you get a CERTIFICATE_VERIFY_FAILED error it clearly does try to use https, so it's a different problem.
the 2 most likely reason why you get a CERTIFICATE_VERIFY_FAILED error is that either the server certificate or one of its signing CA certificates is expired; or the server certificates's CA certificate chain doesn't have a trusted root in the bundled certificates that CPython uses, which i'd assume (but haven't checked) are the bundled certificates of LO's OpenSSL library.
without knowing what the reason of the CERTIFICATE_VERIFY_FAILED error is, it's hard to tell of course...
of course ideally urlib would use the operating system's CA store to verify stuff instead of whatever OpenSSL bundles, which would give the user a UI tool to add additional trusted CA certificates or remove default ones they don't trust - but i have no idea if that is possible.
All I can see is that a very simple urllib.request.urlretreive script works when using the normal Python interpreter but fails when using the built in interpreter that ships with LibreOffice.
(In reply to Leif Lodahl from comment #5)
> All I can see is that a very simple urllib.request.urlretreive script works
> when using the normal Python interpreter but fails when using the built in
> interpreter that ships with LibreOffice.
Could you please attach a simple script that works in normal python and fails in LibreOffice ?
Created attachment 155211 [details]
Example that fails in LibreOffice
This script file can be placed in ~/.config/libreoffice/4/user/Scripts/python
Run from Writer using Tools - Macros - Run macro -> My macros -> InsertImageTest -> download
Created attachment 155212 [details]
This plain Python works
Run with >> python3 InsertImageTestclean.py
Look in the folder.
(In reply to Xisco Faulí from comment #6)
Thank you very much for your effort.
I have attached two wimple scripts. Both scripts should be changed to download to an existing path on your computer.
If you are not using Linux just replace with a path on your harddrive.
[Automated Action] NeedInfo-To-Unconfirmed
Created attachment 156336 [details]
Generic Python module that works
This is a generic Python module that works outside LibreOffice.
Created attachment 156337 [details]
LibreOffice function that calls the generic function
Here is the LibreOffice script that calls the generic Python module.
(change the folder to append in line 3)
In LibreOffice urllib fails.
I added two scripts to the bug.
Ipsum.py is a Python module that returns a piece of text from the web with urlopen.
TestAnything.py is a Python script for LibreOffice that calls the function in Ipsum.py and inserts the text in a Writer document.
(In reply to Leif Lodahl from comment #13)
> I added two scripts to the bug.
> Ipsum.py is a Python module that returns a piece of text from the web with
> TestAnything.py is a Python script for LibreOffice that calls the function
> in Ipsum.py and inserts the text in a Writer document.
> It fails!
com.sun.star.uno.RuntimeException: Error during invoking function insertIpsum in module file:///home/user/libreoffice/instdir/share/Scripts/python/TestAnything.py (<class 'NameError'>: name 'paras' is not defined
File "/home/tonttu/libreoffice/instdir/program/pythonscript.py", line 915, in invoke
ret = self.func( *args )
File "/home/user/libreoffice/instdir/share/Scripts/python/TestAnything.py", line 12, in insertIpsum