1
0
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:
Marcus Huewe 2010-01-20 14:46:10 +01:00
parent f2f948388e
commit 14288a9468
2 changed files with 15 additions and 5 deletions

View File

@ -298,8 +298,6 @@ def init_basicauth(config):
if config['api_host_options'][config['apiurl']]['sslcertck']:
try:
import oscssl
oscssl.myHTTPSConnection.appname = 'osc'
oscssl.myProxyHTTPSConnection.appname = 'osc'
from M2Crypto import m2urllib2
except Exception, e:
print e
@ -357,7 +355,7 @@ def init_basicauth(config):
break
ctx = oscssl.mySSLContext()
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:
import sys
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"

View File

@ -160,6 +160,10 @@ class mySSLContext(SSL.Context):
class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
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
# it's sole purpose is to use our myHTTPSHandler/myHTTPSProxyHandler class
# 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]
if (target_host != host):
h = myProxyHTTPSConnection(host = host, ssl_context = self.ctx)
h = myProxyHTTPSConnection(host = host, appname = self.appname, ssl_context = self.ctx)
else:
h = myHTTPSConnection(host = host, ssl_context = self.ctx)
h = myHTTPSConnection(host = host, appname = self.appname, ssl_context = self.ctx)
# End our change
h.set_debuglevel(self._debuglevel)
@ -217,6 +221,10 @@ class myHTTPSHandler(M2Crypto.m2urllib2.HTTPSHandler):
return resp
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):
M2Crypto.httpslib.HTTPSConnection.connect(self, *args)
verify_certificate(self)
@ -228,6 +236,10 @@ class myHTTPSConnection(M2Crypto.httpslib.HTTPSConnection):
return self.port
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):
M2Crypto.httpslib.ProxyHTTPSConnection._start_ssl(self)
verify_certificate(self)