Downloading SetupTools in Maximo/Jython fails with HTTP error 403 SSL is required
Asked Answered
G

1

7

Appendix A of The Definitive Guide to Jython describes downloading SetupTools for use with Jython.

https://jython.readthedocs.io/en/latest/appendixA/

This indicates to me that it should be possible to download and use SetupTools from within a Jython automation script in Maximo (v7.6 in my case). The book points us to the following url to copy a Jython script that will do this:

http://peak.telecommunity.com/dist/ez_setup.py

I add one line to the above script to call the function "use_setuptools":

use_setuptools()

Then I create a push button on a Maximo application and associate the aforementioned script with the button press I get the following error:

System Message BMXAA7837E - An error occured that prevented the EZ_SETUP script for the EZ_SETUP launch point from running. urllib2.HTTPError: HTTP Error 403: SSL is required in at line number 280

The stack trace points to the following line in the function "download_setuptools" which is called by "use_setuptools":

src = urllib2.urlopen(url)

This appears to be because the url requested, in my case:

http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg

...is redirected a few times before arriving at the following url:

https://files.pythonhosted.org/packages/98/d3/ed3bc7e3f4b143092862dab99d984261ac4be6a40d4fb1e66d2a10e9ea99/setuptools-0.6c11-py2.5.egg

Note the url uses HTTPS not HTTP. The following indicates why this may be so:

https://sourceforge.net/p/pypi/support-requests/300/

The jython.jar included with Maximo does not include the ssl module so we could either:

  1. Download the ssl module manually and copy it to the correct location on the server.
  2. Download the appropriate egg file manually over HTTPS and copy it to the correct location on the server.
  3. Bypass the problem by creating a mirror for the file we're looking for that is accessible over HTTP and use that url in the code.

Whilst these are feasible I'd prefer to modify the code to ignore the SSL certificate if possible, however all the workarounds on StackOverflow and elsewhere seem to require that you're able to "import ssl" in order to bypass it which rather seems to defeat the purpose.

Ideally I'm looking for a solution that modifies the code from the url provided above to get it to work with Maximo/Jython 2.5.2 and doesn't require downloading and adding new modules or packages and all that this entails with Maximo. Bypassing or temporarily disabling ssl is fine as the code checks the hash of the downloaded .egg file. This would be my preferred solution if possible.

Gallonage answered 10/7, 2020 at 16:53 Comment(0)
C
2

In my experience, automation scripting works best if you can stay "as Java as possible" and "as Maximo as possible". So, I would use the LIB_HTTPCLIENT script from the Scripting 76 Features document (the first example code, whose name is given by inference in the second bit of code) to try to download the SetupTools.

In case that document moves again, here is the LIB_HTTPCLIENT script. Note that the url variable is expected to be passed to this library script by the calling script.

from psdi.iface.router import HTTPHandler
from java.util import HashMap
from java.util import String
handler = HTTPHandler()
map = HashMap()
map.put("URL",url)
map.put("HTTPMETHOD","GET")
responseBytes = handler.invoke(map,None)
response = String(responseBytes,"utf-8")
Counterword answered 15/7, 2020 at 15:43 Comment(4)
I appreciate the suggestion but unfortunately this didn't work out either. Using the http url I get the following error: 16 Jul 2020 10:35:29:193 [DEBUG] EZ_SETUP: error - psdi.util.MXSystemException: BMXAA1482E - The response code received from the HTTP request from the endpoint is not successful. If I use the https url it redirects to instead I get a more meaningful error: 16 Jul 2020 10:41:49:680 [DEBUG] EZ_SETUP: error - psdi.util.MXSystemException: BMXAA1477E - The connection failed to the HTTP handler for the endpoint. Received fatal alert: protocol_versionGallonage
Still, all of Maximo was built with the libraries accessible from your script. You may not be able to utilize them all from the confives of an autoscript, but that is a lot of power at your fingertips.Counterword
That protocol error you get when using the HTTPS URL is likely because of TLS v1.2. Chances are the destination requires it but you are using a version of Java that doesn't support it (by default). That's usually the case if you are running on JDK 7 or earlier. I think JDK 8 was the first version to support TLS v1.2 by default.Frictional
@Frictional Apologies, it took me a while to respond but I think you could be right. I had been looking into whether this was related to WebSphere settings but TLS v1.2 makes perfect sense. Thanks for taking the time to reply to me question!Gallonage

© 2022 - 2024 — McMap. All rights reserved.