Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.
The "tools/mod_jk.py" page has been changed by ChristopherSchultz: https://wiki.apache.org/tomcat/tools/mod_jk.py?action=diff&rev1=1&rev2=2 Comment: Updated to add ability to skip TLS hostname verification import os import sys import getopt + import ssl import urllib import urllib2 import xml.etree.ElementTree as ET @@ -48, +49 @@ 'Connection' : 'close' } req = urllib2.Request(url, None, headers) + + # response = urllib2.urlopen(req, context=ctx) response = urllib2.urlopen(req) html = response.read() @@ -96, +99 @@ print('+ Updating ' + server) url = protocol + server + jk_status_path; - headers = { 'User-Agent' : 'mod_jk.py / Python-urllib', + headers = { 'User-Agent' : 'mod_jk.py / Python-urllib', 'Connection' : 'keepalive' } if not balancers: @@ -161, +164 @@ username='' password='' + skip_hostname_verification = False attribute_map = { 'state' : None, @@ -245, +249 @@ if 'workers' in settings: balancers = settings['workers'] if 'attributes' in settings: attributes = settings['attributes'] if 'username' in settings: username = settings['username'][0] + if 'skip_hostname_verification' in settings : skip_hostname_verification = (settings['skip_hostname_verification'][0] in ('true', 'True', 'yes', 'Yes', '1', 'on', 'On')) if 'password' in settings: password = settings['password'][0] if 'jk_status_path' in settings : jk_status_path = settings['jk_status_path'][0] if 'protocol' in settings : protocol = settings['protocol'][0] @@ -257, +262 @@ [password_mgr.add_password(None, url, username, password) for url in server_urls] - handler = urllib2.HTTPBasicAuthHandler(password_mgr) + auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr) + else : + auth_handler = None + if skip_hostname_verification : + ctx = ssl.create_default_context() + ctx.check_hostname = False + host_handler = urllib2.HTTPSHandler(0, context=ctx) + else : + host_handler = None + + if auth_handler or host_handler : + if auth_handler and host_handler : + urllib2.install_opener(urllib2.build_opener(auth_handler, host_handler)) + elif auth_handler : - urllib2.install_opener(urllib2.build_opener(handler)) + urllib2.install_opener(urllib2.build_opener(auth_handler)) + elif host_handler : + urllib2.install_opener(urllib2.build_opener(host_handler)) if changes: update(servers, balancers, workers, changes) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org