/
usr
/
lib64
/
python2.6
/
site-packages
/
M2Crypto
/
/usr/lib64/python2.6/site-packages/M2Crypto
mkdir
upload
Name
Size
Mode
Actions
PGP/
-
0755
rm
SSL/
-
0755
rm
ASN1.py
5614
0644
edit
dl
rm
ASN1.pyc
9462
0644
edit
dl
rm
ASN1.pyo
9063
0644
edit
dl
rm
AuthCookie.py
3085
0644
edit
dl
rm
AuthCookie.pyc
5339
0644
edit
dl
rm
AuthCookie.pyo
5275
0644
edit
dl
rm
BIO.py
7389
0644
edit
dl
rm
BIO.pyc
12186
0644
edit
dl
rm
BIO.pyo
12186
0644
edit
dl
rm
BN.py
1330
0644
edit
dl
rm
BN.pyc
1873
0644
edit
dl
rm
BN.pyo
1873
0644
edit
dl
rm
callback.py
249
0644
edit
dl
rm
callback.pyc
475
0644
edit
dl
rm
callback.pyo
475
0644
edit
dl
rm
DH.py
2374
0644
edit
dl
rm
DH.pyc
4681
0644
edit
dl
rm
DH.pyo
4248
0644
edit
dl
rm
DSA.py
14019
0644
edit
dl
rm
DSA.pyc
17433
0644
edit
dl
rm
DSA.pyo
16845
0644
edit
dl
rm
EC.py
10916
0644
edit
dl
rm
EC.pyc
13287
0644
edit
dl
rm
EC.pyo
12683
0644
edit
dl
rm
Engine.py
3397
0644
edit
dl
rm
Engine.pyc
5492
0644
edit
dl
rm
Engine.pyo
5492
0644
edit
dl
rm
Err.py
1123
0644
edit
dl
rm
Err.pyc
2687
0644
edit
dl
rm
Err.pyo
2687
0644
edit
dl
rm
EVP.py
11810
0644
edit
dl
rm
EVP.pyc
16643
0644
edit
dl
rm
EVP.pyo
16643
0644
edit
dl
rm
ftpslib.py
2881
0644
edit
dl
rm
ftpslib.pyc
3946
0644
edit
dl
rm
ftpslib.pyo
3946
0644
edit
dl
rm
httpslib.py
7861
0644
edit
dl
rm
httpslib.pyc
7797
0644
edit
dl
rm
httpslib.pyo
7699
0644
edit
dl
rm
m2.py
785
0644
edit
dl
rm
m2.pyc
963
0644
edit
dl
rm
m2.pyo
963
0644
edit
dl
rm
m2urllib.py
2124
0644
edit
dl
rm
m2urllib.pyc
2177
0644
edit
dl
rm
m2urllib.pyo
2177
0644
edit
dl
rm
m2urllib2.py
5269
0644
edit
dl
rm
m2urllib2.pyc
5120
0644
edit
dl
rm
m2urllib2.pyo
5065
0644
edit
dl
rm
m2xmlrpclib.py
1928
0644
edit
dl
rm
m2xmlrpclib.pyc
2318
0644
edit
dl
rm
m2xmlrpclib.pyo
2318
0644
edit
dl
rm
Rand.py
488
0644
edit
dl
rm
Rand.pyc
583
0644
edit
dl
rm
Rand.pyo
583
0644
edit
dl
rm
RC4.py
692
0644
edit
dl
rm
RC4.pyc
1634
0644
edit
dl
rm
RC4.pyo
1634
0644
edit
dl
rm
RSA.py
13128
0644
edit
dl
rm
RSA.pyc
17393
0644
edit
dl
rm
RSA.pyo
16991
0644
edit
dl
rm
SMIME.py
7479
0644
edit
dl
rm
SMIME.pyc
10955
0644
edit
dl
rm
SMIME.pyo
10667
0644
edit
dl
rm
threading.py
347
0644
edit
dl
rm
threading.pyc
789
0644
edit
dl
rm
threading.pyo
789
0644
edit
dl
rm
util.py
1588
0644
edit
dl
rm
util.pyc
3081
0644
edit
dl
rm
util.pyo
3081
0644
edit
dl
rm
X509.py
34646
0644
edit
dl
rm
X509.pyc
47271
0644
edit
dl
rm
X509.pyo
44913
0644
edit
dl
rm
__init__.py
1421
0644
edit
dl
rm
__init__.pyc
1980
0644
edit
dl
rm
__init__.pyo
1980
0644
edit
dl
rm
__m2crypto.so
445064
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/M2Crypto/m2urllib2.py
(5269B)
""" M2Crypto enhancement to Python's urllib2 for handling 'https' url's. Code from urllib2 is Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Python Software Foundation; All Rights Reserved Summary of changes: - Use an HTTPSProxyConnection if the request is going through a proxy. - Add the SSL context to the https connection when performing https_open. - Add the M2Crypto HTTPSHandler when building a default opener. """ import socket from urllib2 import * import urlparse import SSL import httpslib class _closing_fileobject(socket._fileobject): '''socket._fileobject that propagates self.close() to the socket. Python 2.5 provides this as socket._fileobject(sock, close=True). ''' def __init__(self, sock): socket._fileobject.__init__(self, sock) def close(self): sock = self._sock socket._fileobject.close(self) sock.close() class HTTPSHandler(AbstractHTTPHandler): def __init__(self, ssl_context = None): AbstractHTTPHandler.__init__(self) if ssl_context is not None: assert isinstance(ssl_context, SSL.Context), ssl_context self.ctx = ssl_context else: self.ctx = SSL.Context() # Copied from urllib2, so we can set the ssl context. def https_open(self, req): """Return an addinfourl object for the request, using http_class. http_class must implement the HTTPConnection API from httplib. The addinfourl return value is a file-like object. It also has methods and attributes including: - info(): return a mimetools.Message object for the headers - geturl(): return the original request URL - code: HTTP status code """ host = req.get_host() if not host: raise URLError('no host given') # Our change: Check to see if we're using a proxy. # Then create an appropriate ssl-aware connection. full_url = req.get_full_url() target_host = urlparse.urlparse(full_url)[1] if (target_host != host): request_uri = urlparse.urldefrag(full_url)[0] h = httpslib.ProxyHTTPSConnection(host = host, ssl_context = self.ctx) else: request_uri = req.get_selector() h = httpslib.HTTPSConnection(host = host, ssl_context = self.ctx) # End our change h.set_debuglevel(self._debuglevel) headers = dict(req.headers) headers.update(req.unredirected_hdrs) # We want to make an HTTP/1.1 request, but the addinfourl # class isn't prepared to deal with a persistent connection. # It will try to read all remaining data from the socket, # which will block while the server waits for the next request. # So make sure the connection gets closed after the (only) # request. headers["Connection"] = "close" try: h.request(req.get_method(), request_uri, req.data, headers) r = h.getresponse() except socket.error, err: # XXX what error? raise URLError(err) # Pick apart the HTTPResponse object to get the addinfourl # object initialized properly. # Wrap the HTTPResponse object in socket's file object adapter # for Windows. That adapter calls recv(), so delegate recv() # to read(). This weird wrapping allows the returned object to # have readline() and readlines() methods. # XXX It might be better to extract the read buffering code # out of socket._fileobject() and into a base class. r.recv = r.read fp = _closing_fileobject(r) resp = addinfourl(fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp https_request = AbstractHTTPHandler.do_request_ # Copied from urllib2 with modifications for ssl def build_opener(ssl_context = None, *handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP and FTP. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ import types def isclass(obj): return isinstance(obj, types.ClassType) or hasattr(obj, "__bases__") opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor] skip = [] for klass in default_classes: for check in handlers: if isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): skip.append(klass) for klass in skip: default_classes.remove(klass) for klass in default_classes: opener.add_handler(klass()) # Add the HTTPS handler with ssl_context if HTTPSHandler not in skip: opener.add_handler(HTTPSHandler(ssl_context)) for h in handlers: if isclass(h): h = h() opener.add_handler(h) return opener
Save
cmd:
run