Example #1
0
        def connect(self):
            "Connect to a host on a given (SSL) port."

            sock = socket_create_connection((self.host, self.port),
                                            self.timeout, self.source_address)

            if self._tunnel_host:
                self.sock = sock
                self._tunnel()

            server_hostname = self.host if ssl.HAS_SNI else None
            self.sock = self._context.wrap_socket(
                sock, server_hostname=server_hostname)
            try:
                if self._check_hostname:
                    ssl.match_hostname(self.sock.getpeercert(), self.host)
            except Exception:
                self.sock.shutdown(socket.SHUT_RDWR)
                self.sock.close()
                raise
Example #2
0
        def connect(self):
            "Connect to a host on a given (SSL) port."

            sock = socket_create_connection((self.host, self.port),
                                            self.timeout, self.source_address)

            if self._tunnel_host:
                self.sock = sock
                self._tunnel()

            server_hostname = self.host if ssl.HAS_SNI else None
            self.sock = self._context.wrap_socket(sock,
                                                  server_hostname=server_hostname)
            try:
                if self._check_hostname:
                    ssl.match_hostname(self.sock.getpeercert(), self.host)
            except Exception:
                self.sock.shutdown(socket.SHUT_RDWR)
                self.sock.close()
                raise
Example #3
0
 def connect(self):
     """Connect to the host and port specified in __init__."""
     self.sock = socket_create_connection((self.host, self.port),
                                          self.timeout, self.source_address)
     if self._tunnel_host:
         self._tunnel()
Example #4
0
 def connect(self):
     """Connect to the host and port specified in __init__."""
     self.sock = socket_create_connection((self.host,self.port),
                                          self.timeout, self.source_address)
     if self._tunnel_host:
         self._tunnel()