def __init__(self, ssl_context=None): AbstractHTTPHandler.__init__(self) if ssl_context is not None: self.ctx = ssl_context else: self.ctx = SSL.Context()
def __init__(self, ssl_context=None, *args, **kw): if getattr(Transport, '__init__', None) is not None: Transport.__init__(self, *args, **kw) if ssl_context is None: self.ssl_ctx = SSL.Context('sslv23') else: self.ssl_ctx = ssl_context
def test(): context = SSL.Context(SSL.TLSv1_METHOD) sock = socket.create_connection(('www.google.com', 443), timeout=2) connection = SSL.Connection(context, sock) connection.set_connect_state() connection.do_handshake() connection.send('GET / HTTP/1.1\r\n\r\n') print(connection.recv(1024))
def __init__(self, host=None, ssl_ctx=None): """Initialise the client. If 'host' is supplied, connect to it.""" if ssl_ctx is not None: self.ssl_ctx = ssl_ctx else: self.ssl_ctx = SSL.Context(DEFAULT_PROTOCOL) FTP.__init__(self, host) self.prot = 0
def __init__(self, host='', port=None, strict=None, **ssl): HTTP.__init__(self, host, port, strict) try: self.ssl_ctx = ssl['ssl_context'] except KeyError: self.ssl_ctx = SSL.Context('sslv23') assert isinstance(self._conn, HTTPSConnection) self._conn.ssl_ctx = self.ssl_ctx
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()
def open_https(self, url, data=None, ssl_context=None): if ssl_context is not None and isinstance(ssl_context, SSL.Context): self.ctx = ssl_context else: self.ctx = SSL.Context(DEFAULT_PROTOCOL) user_passwd = None if type(url) is type(""): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base_64 auth = string.strip(base_64.encodestring(user_passwd)) else: auth = None # Start here! h = httpslib.HTTPSConnection(host=host, ssl_context=self.ctx) #h.set_debuglevel(1) # Stop here! if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') # Here again! resp = h.getresponse() fp = resp.fp return urllib.addinfourl(fp, resp.msg, "https:" + url)
def __init__(self, host, port=None, **ssl): keys = ssl.keys() try: keys.remove('key_file') except ValueError: pass try: keys.remove('cert_file') except ValueError: pass try: keys.remove('ssl_context') except ValueError: pass if keys: raise ValueError() try: self.ssl_ctx = ssl['ssl_context'] assert isinstance(self.ssl_ctx, SSL.Context) except KeyError: self.ssl_ctx = SSL.Context('sslv23') HTTPConnection.__init__(self, host, port)
def __init__(self, host, port=None, strict=None, **ssl): self.session = None keys = ssl.keys() try: keys.remove('key_file') except ValueError: pass try: keys.remove('cert_file') except ValueError: pass try: keys.remove('ssl_context') except ValueError: pass if keys: raise ValueError('unknown keyword argument') try: self.ssl_ctx = ssl['ssl_context'] assert isinstance(self.ssl_ctx, SSL.Context), self.ssl_ctx except KeyError: self.ssl_ctx = SSL.Context('sslv23') HTTPConnection.__init__(self, host, port, strict)
def __init__(self, host='', port=None, **ssl): HTTP.__init__(self, host, port) try: self.ssl_ctx = ssl['ssl_context'] except KeyError: self.ssl_ctx = SSL.Context('sslv23')
def __init__(self, ssl_context=None): if ssl_context is None: self.ssl_ctx=SSL.Context('sslv23') else: self.ssl_ctx=ssl_context