HTTPRequest Plugin - v0.1.0

Questions and comments specific to a particular plugin should go here.
User avatar
Luca Brasi
Experienced User
Posts: 250
Joined: Sat Oct 11, 2008 12:39 pm

Re: HTTPRequest Plugin - v0.1.0

Post by Luca Brasi » Tue Aug 22, 2017 7:13 am

hi,

great that you already improved your plugin. Thanks for that.
It will not work for me though as soon as I use cert verification. It's the as when I used Requests directly from a script as posted earlier.

Code: Select all

09:09:09   HTTPRequest: GET https://google.de/
09:09:09      Fehler in Befehl: "HTTPRequest: GET https://google.de/"
09:09:09      Traceback (most recent call last) (0.5.0-rc4):
09:09:09        File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 116, in CallWrapper
09:09:09          return self(*args)
09:09:09        File "C:\ProgramData\EventGhost\plugins\HTTPRequest\__init__.py", line 58, in __call__
09:09:09          stream=False)
09:09:09        File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\api.py", line 57, in request
09:09:09          return session.request(method=method, url=url, **kwargs)
09:09:09        File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\sessions.py", line 475, in request
09:09:09          resp = self.send(prep, **send_kwargs)
09:09:09        File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\sessions.py", line 585, in send
09:09:09          r = adapter.send(request, **kwargs)
09:09:09        File "C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\adapters.py", line 477, in send
09:09:09          raise SSLError(e, request=request)
09:09:09      SSLError: [Errno 2] No such file or directory
Don't you guys get this error?

If I turn off the verification it will work. I'll get this warning though...

Code: Select all

09:10:43   HTTPRequest: GET https://www.google.de/
09:10:43      HTTPRequest: GET https://google.de/
09:10:43         C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
09:10:43           InsecureRequestWarning)
09:10:43         C:\Program Files (x86)\EventGhost\lib27\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
09:10:43           InsecureRequestWarning)
09:10:43      print results
09:10:43         <Response [200]>
09:10:43         <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="de"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title>
[...........]
</script></div></body></html>

[Edit: ]

I did some digging. This seems to happen because of python is not able to access trusted root CA files on the system. I found some solutions for linux systems but have no clue how python is supposed to work on windows here. Maybe this can be of any help: https://stackoverflow.com/questions/277 ... -directory
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: HTTPRequest Plugin - v0.1.0

Post by Boolean263 » Tue Aug 22, 2017 2:19 pm

Luca Brasi wrote:great that you already improved your plugin. Thanks for that.
It will not work for me though as soon as I use cert verification. It's the as when I used Requests directly from a script as posted earlier.
Like you say, the "problem" is with Requests -- though really, Windows is to blame here too. Judging from the link you shared, Requests needs a path to your system's CA certificate files, but Windows doesn't store its certificates in files; it uses the registry.

Were you able to access SSL sites with the original (httplib) version of the HTTPRequest plugin? If so, that might give us a clue as to how to make Requests work, both in general and in this plugin.

Edit: Aha! Look what happens when I actually read the documentation:
By default, Requests bundles a set of root CAs that it trusts, sourced from the Mozilla trust store. However, these are only updated once for each Requests version. This means that if you pin a Requests version your certificates can become extremely out of date.

From Requests version 2.4.0 onwards, Requests will attempt to use certificates from certifi if it is present on the system. This allows for users to update their trusted certificates without having to change the code that runs on their system.

For the sake of security we recommend upgrading certifi frequently!
(emphasis mine, links removed)

So that means we're shipping CA cert bundles with EventGhost, whether we realize it or not, and those certs have gotten out of date for your needs.
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

User avatar
kgschlosser
Site Admin
Posts: 2900
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Tue Aug 22, 2017 9:51 pm

the pem file that is included with requests is made by openSSL. but this gives you a means to get rid if the security warning

https://stackoverflow.com/questions/154 ... n-requests
If you like the work I have been doing then feel free to Image

User avatar
Boolean263
Plugin Developer
Posts: 81
Joined: Sat Aug 12, 2017 7:52 pm
Location: Ottawa, Canada
Contact:

Re: HTTPRequest Plugin - v0.1.0

Post by Boolean263 » Tue Aug 22, 2017 10:17 pm

kgschlosser wrote:the pem file that is included with requests is made by openSSL. but this gives you a means to get rid if the security warning

https://stackoverflow.com/questions/154 ... n-requests
While it's good to know how to disable SSL verification, that's not a good long-term solution. SSL warnings exist for a reason.

As I noted in my post, the developers of Requests have stated that the pem file that they ship with Requests is liable to become out of date. This is what leads to the errors Luca Brasi is seeing. EventGhost needs to provide a more up-to-date version of the pem file, or else provide instructions for end users to be able to update the file for themselves.
Windows 10 Home, version 1703, build 15063.540 · EventGhost 0.5.0-rc4 · wxPython 3.0.2.0
Python programmer for fun and profit. Dabbler in EventGhost plugin writing. Wiki gardener. General geek.

User avatar
Pako
Plugin Developer
Posts: 2262
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: HTTPRequest Plugin - v0.1.0

Post by Pako » Wed Aug 23, 2017 5:45 am

Boolean263 wrote:EventGhost needs to provide a more up-to-date version of the pem file, or else provide instructions for end users to be able to update the file for themselves.
Perhaps there is another way. You can consider (try) the use of pycurl instead of Requests.
I was forced to do it (for a similar reason) in the Pushbullet plugin when it suddenly stopped working from day to day. Since then, pycurl has become an integral part of Eventghost installation (at least in version 4).
Of course, I'm not sure it will help in your case.

Pako

User avatar
kgschlosser
Site Admin
Posts: 2900
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Wed Aug 23, 2017 3:06 pm

IDK if pycurl has been removed form EG 0.5. I would have to go and look. if it has i will add it back again as this is something that should be apart of the EG standard lib.
If you like the work I have been doing then feel free to Image

Sem;colon
Experienced User
Posts: 579
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: HTTPRequest Plugin - v0.1.0

Post by Sem;colon » Sun Sep 03, 2017 9:33 pm

Just for the record, the Webserver Plugin also has the posibillity to send http requests... (Actiin : Send request to another Webserver) :wink:

Post Reply