def __init__(self, host, port=None, key_file=None, cert_file=None,
		strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None,
		ca_file=None):
			HTTPSConnection.__init__(self, host, port, key_file,
				cert_file, strict, timeout, source_address)

			self.ca_file = ca_file
Esempio n. 2
0
 def __init__(self, host, port, timeout):
     proxy = os.environ.get("https_proxy")
     (self.proxy_host,self.proxy_port, path, ssl) = parse_url(proxy)
     self.target_host = host
     self.target_port = port
     HTTPSConnection.__init__(self, self.proxy_host, self.proxy_port)
     self.timeout = timeout
Esempio n. 3
0
    def __init__(self, host, port=None, key_file=None, cert_file=None,
                 strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                 source_address=None, context=None, handler=None):
        HTTPSConnection.__init__(self, host, port=port, key_file=key_file, cert_file=cert_file,
                                 strict=strict, timeout=timeout,
                                 source_address=source_address, context=context)

        self.handler = handler
Esempio n. 4
0
 def __init__(self, host, port, key_file, cert_file, ca_file,
              cert_required=False, timeout=1.0):
     if sys.version_info < (2, 6):
         HTTPSConnection.__init__(self, host, port, key_file, cert_file)
     else:
         HTTPSConnection.__init__(self, host, port, key_file, cert_file,
                                  timeout=timeout)
     self._ca_file = ca_file
     self._cert_required = cert_required
Esempio n. 5
0
 def __init__(self, host, url, cookie=None, params=None):
     "init"
     self.url = url
     if not self.url.startswith('/'):
         self.url = '/' + self.url
     if not self.url.endswith('/'):
         self.url = self.url + '/'
     if cookie:
         self.headers['Cookie'] = cookie
     self.params = params
     HTTPConnection.__init__(self, host)
 def __init__(self, host, port=443):
     if 'X509_USER_CERT' in os.environ and 'X509_USER_KEY' in os.environ:
         certfile = os.environ['X509_USER_CERT']
         keyfile = os.environ['X509_USER_KEY']
     elif 'X509_USER_PROXY' in os.environ:
         keyfile = os.environ['X509_USER_PROXY']
         certfile = os.environ['X509_USER_PROXY']
     else:
         certfile = os.path.expandvars('$HOME/.globus/usercert.pem')
         keyfile = os.path.expandvars('$HOME/.globus/userkey.pem')
     HTTPSConnection.__init__(self, host, port, keyfile, certfile)
Esempio n. 7
0
 def __init__(self, cert, *args):
     try:
         # read the certificate
         c   = open(cert, "r").read()
         # extract the publickey information
         pki = extractPubKey(c)
         # store its SHA256 hash
         self.pHash = SHA256.new(pki).digest()
     except:
         raise IOError, ("Can't open certificate: %s" % cert)
     
     HTTPSConnection.__init__(self, *args)
Esempio n. 8
0
    def __init__(self, host, port=None, key_file=None, cert_file=None,
                 strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                 ca_certs=None):
        """
        Adds the ca_certs argument.

        @param ca_certs: File containing a concatination of x509
                         CA certificates that are trusted for verifying
                         the certificate of the remote server.
        """
        HTTPSConnection.__init__(self, host, port, key_file, cert_file,
                                 strict, timeout)
        self.ca_certs = ca_certs
Esempio n. 9
0
 def __init__(self, host, port=None, key_file=None, cert_file=None,
              cacert=None, timeout=None, insecure=False,
              ssl_compression=True):
     _HTTPSConnection.__init__(self, host, port,
                               key_file=key_file,
                               cert_file=cert_file)
     self.key_file = key_file
     self.cert_file = cert_file
     self.timeout = timeout
     self.insecure = insecure
     self.ssl_compression = ssl_compression
     self.cacert = cacert
     self.setcontext()
Esempio n. 10
0
    def __init__(self,
                 host,
                 port=None,
                 ca_file=None,
                 **kwargs):
        HTTPSConnection.__init__(self,
                                 host=host,
                                 port=port,
                                 **kwargs)

        if ca_file:
            self.ca_file = ca_file
        else:
            self.ca_file = os.path.join(os.path.dirname(__file__), 'DigiCertRoots.pem')
Esempio n. 11
0
    def __init__(self,
                 host,
                 port,
                 credentials,
                 pkey_file=None,
                 cert_file=None,
                 timeout=None):
        """
        Class to make a HTTPS connection,
        with support for full client-based SSL Authentication

        :param host: Riak host name
        :type host: str
        :param port: Riak host port number
        :type port: int
        :param credentials: Security Credential settings
        :type  credentials: SecurityCreds
        :param pkey_file: PEM formatted file that contains your private key
        :type pkey_file: str
        :param cert_file: PEM formatted certificate chain file
        :type cert_file: str
        :param timeout: Number of seconds before timing out
        :type timeout: int
        """
        if PY2:
            # NB: it appears that pkey_file / cert_file are never set
            # in riak/transports/http/connection.py#_connect() method
            pkf = pkey_file
            if pkf is None and credentials is not None:
                pkf = credentials._pkey_file

            cf = cert_file
            if cf is None and credentials is not None:
                cf = credentials._cert_file

            HTTPSConnection.__init__(self,
                                     host,
                                     port,
                                     key_file=pkf,
                                     cert_file=cf)
        else:
            super(RiakHTTPSConnection, self). \
                __init__(host=host,
                         port=port,
                         key_file=credentials._pkey_file,
                         cert_file=credentials._cert_file)
        self.pkey_file = pkey_file
        self.cert_file = cert_file
        self.credentials = credentials
        self.timeout = timeout
Esempio n. 12
0
    def __init__(self,
                 host,
                 port,
                 credentials,
                 pkey_file=None,
                 cert_file=None,
                 timeout=None):
        """
        Class to make a HTTPS connection,
        with support for full client-based SSL Authentication

        :param host: Riak host name
        :type host: str
        :param port: Riak host port number
        :type port: int
        :param credentials: Security Credential settings
        :type  credentials: SecurityCreds
        :param pkey_file: PEM formatted file that contains your private key
        :type pkey_file: str
        :param cert_file: PEM formatted certificate chain file
        :type cert_file: str
        :param timeout: Number of seconds before timing out
        :type timeout: int
        """
        if PY2:
            # NB: it appears that pkey_file / cert_file are never set
            # in riak/transports/http/connection.py#_connect() method
            pkf = pkey_file
            if pkf is None and credentials is not None:
                pkf = credentials._pkey_file

            cf = cert_file
            if cf is None and credentials is not None:
                cf = credentials._cert_file

            HTTPSConnection.__init__(self,
                                     host,
                                     port,
                                     key_file=pkf,
                                     cert_file=cf)
        else:
            super(RiakHTTPSConnection, self). \
                __init__(host=host,
                         port=port,
                         key_file=credentials._pkey_file,
                         cert_file=credentials._cert_file)
        self.pkey_file = pkey_file
        self.cert_file = cert_file
        self.credentials = credentials
        self.timeout = timeout
Esempio n. 13
0
    def __init__(self, host, port=None, strict=None, **kwargs):

        self.proxy_host = None
        self.proxy_port = None
        if os.environ.has_key('https_proxy'):
            o = urlparse(os.environ['https_proxy'])
            try:
                self.proxy_host, self.proxy_port = o[1].split(':')
            except:
                pass
        HTTPSConnection.__init__(self, host=host,
                                       port=port,
                                       strict=strict,
                                       **kwargs)
Esempio n. 14
0
  def __init__(self, host, *args, **kwargs):
    key_file = None
    cert_file = None

    x509_path = getenv("X509_USER_PROXY", None)
    if x509_path and exists(x509_path):
      key_file = cert_file = x509_path

    if not key_file:
      x509_path = getenv("X509_USER_KEY", None)
      if x509_path and exists(x509_path):
        key_file = x509_path

    if not cert_file:
      x509_path = getenv("X509_USER_CERT", None)
      if x509_path and exists(x509_path):
        cert_file = x509_path

    if not key_file:
      x509_path = getenv("HOME") + "/.globus/userkey.pem"
      if exists(x509_path):
        key_file = x509_path

    if not cert_file:
      x509_path = getenv("HOME") + "/.globus/usercert.pem"
      if exists(x509_path):
        cert_file = x509_path

    if not key_file or not exists(key_file):
      print >>stderr, "No certificate private key file found"
      exit(1)

    if not cert_file or not exists(cert_file):
      print >>stderr, "No certificate public key file found"
      exit(1)

    #print "Using SSL private key", key_file
    #print "Using SSL public key", cert_file
    
    HTTPSConnection.__init__(self, 
                              host,
                              key_file = key_file,
                              cert_file = cert_file,
                              **kwargs)
Esempio n. 15
0
    def __init__(self, host, *args, **kwargs):
        key_file = None
        cert_file = None

        x509_path = getenv("X509_USER_PROXY", None)
        if x509_path and exists(x509_path):
            key_file = cert_file = x509_path

        if not key_file:
            x509_path = getenv("X509_USER_KEY", None)
            if x509_path and exists(x509_path):
                key_file = x509_path

        if not cert_file:
            x509_path = getenv("X509_USER_CERT", None)
            if x509_path and exists(x509_path):
                cert_file = x509_path

        if not key_file:
            x509_path = getenv("HOME") + "/.globus/userkey.pem"
            if exists(x509_path):
                key_file = x509_path

        if not cert_file:
            x509_path = getenv("HOME") + "/.globus/usercert.pem"
            if exists(x509_path):
                cert_file = x509_path

        if not key_file or not exists(key_file):
            print("No certificate private key file found", file=stderr)
            exit(1)

        if not cert_file or not exists(cert_file):
            print("No certificate public key file found", file=stderr)
            exit(1)

        #print "Using SSL private key", key_file
        #print "Using SSL public key", cert_file

        HTTPSConnection.__init__(self,
                                 host,
                                 key_file=key_file,
                                 cert_file=cert_file,
                                 **kwargs)
Esempio n. 16
0
 def __init__(self,
              host,
              port=None,
              key_file=None,
              cert_file=None,
              strict=None,
              timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
              source_address=None,
              response_wrapper=NOT_SET):
     _HTTPSConnection.__init__(self,
                               host,
                               port,
                               key_file=key_file,
                               cert_file=cert_file,
                               strict=strict,
                               timeout=timeout,
                               source_address=source_address)
     if response_wrapper is not NOT_SET:
         self.response_wrapper = response_wrapper
Esempio n. 17
0
 def __init__(self,
              host,
              port=None,
              key_file=None,
              cert_file=None,
              cacert=None,
              timeout=None,
              insecure=False,
              ssl_compression=True):
     _HTTPSConnection.__init__(self,
                               host,
                               port,
                               key_file=key_file,
                               cert_file=cert_file)
     self.key_file = key_file
     self.cert_file = cert_file
     self.timeout = timeout
     self.insecure = insecure
     self.ssl_compression = ssl_compression
     self.cacert = cacert
     self.setcontext()
Esempio n. 18
0
    def __init__(self,
                 host,
                 port,
                 credentials,
                 pkey_file=None,
                 cert_file=None,
                 timeout=None):
        """
        Class to make a HTTPS connection,
        with support for full client-based SSL Authentication

        :param host: Riak host name
        :type host: str
        :param port: Riak host port number
        :type port: int
        :param credentials: Security Credential settings
        :type  credentials: SecurityCreds
        :param pkey_file: PEM formatted file that contains your private key
        :type pkey_file: str
        :param cert_file: PEM formatted certificate chain file
        :type cert_file: str
        :param timeout: Number of seconds before timing out
        :type timeout: int
        """
        if PY2:
            HTTPSConnection.__init__(self,
                                     host,
                                     port,
                                     key_file=pkey_file,
                                     cert_file=cert_file)
        else:
            super(RiakHTTPSConnection, self). \
                __init__(host=host,
                         port=port,
                         key_file=credentials._pkey_file,
                         cert_file=credentials._cert_file)
        self.pkey_file = pkey_file
        self.cert_file = cert_file
        self.credentials = credentials
        self.timeout = timeout
Esempio n. 19
0
    def __init__(self,
                 host,
                 port,
                 credentials,
                 pkey_file=None,
                 cert_file=None,
                 timeout=None):
        """
        Class to make a HTTPS connection,
        with support for full client-based SSL Authentication

        :param host: Riak host name
        :type host: str
        :param port: Riak host port number
        :type port: int
        :param credentials: Security Credential settings
        :type  credentials: SecurityCreds
        :param pkey_file: PEM formatted file that contains your private key
        :type pkey_file: str
        :param cert_file: PEM formatted certificate chain file
        :type cert_file: str
        :param timeout: Number of seconds before timing out
        :type timeout: int
        """
        if PY2:
            HTTPSConnection.__init__(self,
                                     host,
                                     port,
                                     key_file=pkey_file,
                                     cert_file=cert_file)
        else:
            super(RiakHTTPSConnection, self). \
                __init__(host=host,
                         port=port,
                         key_file=credentials._pkey_file,
                         cert_file=credentials._cert_file)
        self.pkey_file = pkey_file
        self.cert_file = cert_file
        self.credentials = credentials
        self.timeout = timeout
Esempio n. 20
0
        def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
            '''
            Constructor. It delegates construction to the base class
            HTTPConnection and initializes the new member variables
            with the default values from the Python documentation

            @param host: host to connect to
            @type host: str
            @param port: port to connect to. use None for the default HTTP port
            @type port: int|None
            @param key_file: path to private key_file or None if stored in cert_file
            @type key_file: str|None
            @param cert_file: path to certificate to be used for validation or None
            @type cert_file: str|None
            @param strict: n/a
            @type strict: Unknown
            @param timeout: default time for network operations
            @type timeout: float
            '''
            HTTPSConnection.__init__(self, host, port, key_file, cert_file, strict, timeout)
            self.cert_reqs = ssl.CERT_NONE
            self.ca_certs = None
    def __init__(self, host, port=None, key_file=None, cert_file=None,
                 strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                 ca_certs=None):
        """
        Adds the ca_certs argument.

        @param ca_certs: File containing a concatination of x509
                         CA certificates that are trusted for verifying
                         the certificate of the remote server.
        """
        proxy = get_proxy()
        if proxy:
            real_host, real_port = host, port
            host, port = proxy

        HTTPSConnection.__init__(self, host, port, key_file, cert_file,
                                 strict, timeout)
        if proxy:
            if hasattr(self, "set_tunnel"):     # Python 2.7+
                self.set_tunnel(real_host, real_port)
            elif hasattr(self, "_set_tunnel"):  # Python 2.6.6 (private)
                self._set_tunnel(real_host, real_port)

        self.ca_certs = ca_certs
Esempio n. 22
0
File: http.py Progetto: gddc/xsi
 def __init__(self, *args, **kwargs):
   HTTPSConnection.__init__(self, *args, **kwargs)
   self.response_class = MyResponse
 def __init__(self, host, **kwargs):
     self._ca_certs = kwargs.pop('ca_certs', None)
     HTTPSConnection.__init__(self, host, **kwargs)
Esempio n. 24
0
 def __init__(self, host, **kwargs):
     self._ca_certs = kwargs.pop('ca_certs', None)
     HTTPSConnection.__init__(self, host, **kwargs)
Esempio n. 25
0
 def __init__(self, host, ca_file=None):
     HTTPSConnection.__init__(self, host)
     self.__ca_file = ca_file
Esempio n. 26
0
 def __init__(self, host, port=None, strict=None):
     HTTPSConnection.__init__(self, host, port, strict=strict)
     self.request_length = 0
Esempio n. 27
0
 def __init__(self, host, port, ca_certs):
     HTTPSConnection.__init__(self, host, port)
     self.ca_certs = ca_certs
Esempio n. 28
0
 def __init__(self, *args, **kwargs):
     self.ss_client = kwargs.pop('ss_client')
     HTTPSConnection.__init__(self, *args, **kwargs)
Esempio n. 29
0
 def __init__(self, *args, **kwargs):
     HTTPSConnection.__init__(self, *args, **kwargs)
     self.response_class = MyResponse
Esempio n. 30
0
 def __init__(self, host, *args, **kwargs):
   HTTPSConnection.__init__(self, host, key_file = x509_proxy,
                            cert_file = x509_proxy, **kwargs)
 def __init__(self, host):
     HTTPSConnection.__init__(self, host)
     self.setcontext()
Esempio n. 32
0
 def __init__(self, host, *args, **kwargs):
   HTTPSConnection.__init__(self, host, key_file = ssl_key_file,
                cert_file = ssl_cert_file, **kwargs)
 def __init__(self, host, port, ca_certs):
     HTTPSConnection.__init__(self, host, port)
     self.ca_certs = ca_certs
Esempio n. 34
0
 def __init__(self, host, port=None, timeout=20, **kwargs):
     if not hasattr(socket, 'ssl'):
         raise ValueError(
             'This Python installation does not have SSL support.')
     HTTPSConnection.__init__(self, str(host), port, **kwargs)
     self.timeout = timeout
Esempio n. 35
0
 def __init__(self, path, *args, **kwargs):
     HTTPSConnection.__init__(self, *args, **kwargs)
     self.path = path
Esempio n. 36
0
	def __init__(self, host, port=None, key_file = None, cert_file = None, strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, response_wrapper = NOT_SET):
		_HTTPSConnection.__init__(self, host, port, key_file = key_file, cert_file = cert_file, strict = strict, timeout = timeout, source_address = source_address)
		if response_wrapper is not NOT_SET:
			self.response_wrapper = response_wrapper
Esempio n. 37
0
 def __init__(self, host, *args, **kwargs):
     HTTPSConnection.__init__(self,
                              host,
                              key_file=x509_proxy,
                              cert_file=x509_proxy,
                              **kwargs)
Esempio n. 38
0
 def __init__(self, host, port, key_file, cert_file, ca_file, timeout=None):
     HTTPSConnection.__init__(self, host, key_file=key_file, cert_file=cert_file)
     self.key_file = key_file
     self.cert_file = cert_file
     self.ca_file = ca_file
     self.timeout = timeout
Esempio n. 39
0
 def __init__(self, host, port=None, strict=None):
     HTTPSConnection.__init__(self, host, port, strict=strict)
     self.request_length = 0
Esempio n. 40
0
 def __init__(self, host, port, timeout):
     HTTPSConnection.__init__(self, host, port)
     self.timeout = timeout
Esempio n. 41
0
 def __init__(self, host):
     HTTPSConnection.__init__(self, host)
     self.setcontext()
Esempio n. 42
0
 def __init__(self, host, port, timeout):
     HTTPSConnection.__init__(self, host,port)
     self.timeout = timeout
Esempio n. 43
0
 def __init__(self, host, port=None, timeout=20, **kwargs):
     HTTPSConnection.__init__(self, str(host), port, **kwargs)
     self.timeout = timeout
Esempio n. 44
0
 def __init__(self, path, *args, **kwargs):
     HTTPSConnection.__init__(self, *args, **kwargs)
     self.path = path