mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-25 19:52:12 +01:00
- changed appname handling
This commit is contained in:
parent
f2f948388e
commit
14288a9468
@ -298,8 +298,6 @@ def init_basicauth(config):
|
|||||||
if config['api_host_options'][config['apiurl']]['sslcertck']:
|
if config['api_host_options'][config['apiurl']]['sslcertck']:
|
||||||
try:
|
try:
|
||||||
import oscssl
|
import oscssl
|
||||||
oscssl.myHTTPSConnection.appname = 'osc'
|
|
||||||
oscssl.myProxyHTTPSConnection.appname = 'osc'
|
|
||||||
from M2Crypto import m2urllib2
|
from M2Crypto import m2urllib2
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
@ -357,7 +355,7 @@ def init_basicauth(config):
|
|||||||
break
|
break
|
||||||
ctx = oscssl.mySSLContext()
|
ctx = oscssl.mySSLContext()
|
||||||
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
||||||
opener = m2urllib2.build_opener(ctx, oscssl.myHTTPSHandler(ctx), urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
opener = m2urllib2.build_opener(ctx, oscssl.myHTTPSHandler(ssl_context = ctx, appname = 'osc'), urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
||||||
else:
|
else:
|
||||||
import sys
|
import sys
|
||||||
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
||||||
|
@ -160,6 +160,10 @@ class mySSLContext(SSL.Context):
|
|||||||
class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
|
class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
|
||||||
handler_order = 499
|
handler_order = 499
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.appname = kwargs.pop('appname', 'generic')
|
||||||
|
M2Crypto.m2urllib2.HTTPSHandler.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
# copied from M2Crypto.m2urllib2.HTTPSHandler
|
# copied from M2Crypto.m2urllib2.HTTPSHandler
|
||||||
# it's sole purpose is to use our myHTTPSHandler/myHTTPSProxyHandler class
|
# it's sole purpose is to use our myHTTPSHandler/myHTTPSProxyHandler class
|
||||||
# ideally the m2urllib2.HTTPSHandler.https_open() method would be split into
|
# ideally the m2urllib2.HTTPSHandler.https_open() method would be split into
|
||||||
@ -176,9 +180,9 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
|
|||||||
target_host = urlparse.urlparse(full_url)[1]
|
target_host = urlparse.urlparse(full_url)[1]
|
||||||
|
|
||||||
if (target_host != host):
|
if (target_host != host):
|
||||||
h = myProxyHTTPSConnection(host = host, ssl_context = self.ctx)
|
h = myProxyHTTPSConnection(host = host, appname = self.appname, ssl_context = self.ctx)
|
||||||
else:
|
else:
|
||||||
h = myHTTPSConnection(host = host, ssl_context = self.ctx)
|
h = myHTTPSConnection(host = host, appname = self.appname, ssl_context = self.ctx)
|
||||||
# End our change
|
# End our change
|
||||||
h.set_debuglevel(self._debuglevel)
|
h.set_debuglevel(self._debuglevel)
|
||||||
|
|
||||||
@ -217,6 +221,10 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
class myHTTPSConnection(M2Crypto.httpslib.HTTPSConnection):
|
class myHTTPSConnection(M2Crypto.httpslib.HTTPSConnection):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.appname = kwargs.pop('appname', 'generic')
|
||||||
|
M2Crypto.httpslib.HTTPSConnection.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def connect(self, *args):
|
def connect(self, *args):
|
||||||
M2Crypto.httpslib.HTTPSConnection.connect(self, *args)
|
M2Crypto.httpslib.HTTPSConnection.connect(self, *args)
|
||||||
verify_certificate(self)
|
verify_certificate(self)
|
||||||
@ -228,6 +236,10 @@ class myHTTPSConnection(M2Crypto.httpslib.HTTPSConnection):
|
|||||||
return self.port
|
return self.port
|
||||||
|
|
||||||
class myProxyHTTPSConnection(M2Crypto.httpslib.ProxyHTTPSConnection):
|
class myProxyHTTPSConnection(M2Crypto.httpslib.ProxyHTTPSConnection):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.appname = kwargs.pop('appname', 'generic')
|
||||||
|
M2Crypto.httpslib.ProxyHTTPSConnection.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def _start_ssl(self):
|
def _start_ssl(self):
|
||||||
M2Crypto.httpslib.ProxyHTTPSConnection._start_ssl(self)
|
M2Crypto.httpslib.ProxyHTTPSConnection._start_ssl(self)
|
||||||
verify_certificate(self)
|
verify_certificate(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user