Exemplo n.º 1
0
 def _real_connect(self, addr, connect_ex):
     if self.server_side:
         raise ValueError("can't connect in server-side mode")
     # Here we assume that the socket is client-side, and not
     # connected at the time of the call.  We connect it, then wrap it.
     if self._connected:
         raise ValueError("attempt to connect already-connected SSLSocket!")
     self._sslobj = self._context._wrap_socket(self._sock, False,
                                               self.server_hostname)
     if self._session is not None:  # 3.6+
         self._sslobj = _SSLObject_factory(self._sslobj,
                                           owner=self,
                                           session=self._session)
     try:
         if connect_ex:
             rc = socket.connect_ex(self, addr)
         else:
             rc = None
             socket.connect(self, addr)
         if not rc:
             if self.do_handshake_on_connect:
                 self.do_handshake()
             self._connected = True
         return rc
     except socket_error:
         self._sslobj = None
         raise
Exemplo n.º 2
0
 def connect(self, addr):
     """Connects to remote ADDR, and then wraps the connection in
     an SSL channel."""
     # Here we assume that the socket is client-side, and not
     # connected at the time of the call.  We connect it, then wrap it.
     if self._sslobj:
         raise ValueError("attempt to connect already-connected SSLSocket!")
     socket.connect(self, addr)
     if self.ciphers is None:
         self._sslobj = _ssl.sslwrap(
             self._sock, False, self.keyfile, self.certfile, self.cert_reqs, self.ssl_version, self.ca_certs
         )
     else:
         self._sslobj = _ssl.sslwrap(
             self._sock,
             False,
             self.keyfile,
             self.certfile,
             self.cert_reqs,
             self.ssl_version,
             self.ca_certs,
             self.ciphers,
         )
     if self.do_handshake_on_connect:
         self.do_handshake()
Exemplo n.º 3
0
 def connect(self, addr):
     """Connects to remote ADDR, and then wraps the connection in
     an SSL channel."""
     # Here we assume that the socket is client-side, and not
     # connected at the time of the call.  We connect it, then wrap it.
     if self._sslobj:
         raise ValueError("attempt to connect already-connected SSLSocket!")
     socket.connect(self, addr)
     self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile,
                                 self.certfile, self.cert_reqs,
                                 self.ssl_version, self.ca_certs)
     if self.do_handshake_on_connect:
         self.do_handshake()
Exemplo n.º 4
0
 def _real_connect(self, addr, connect_ex):
     if self.server_side:
         raise ValueError("can't connect in server-side mode")
     # Here we assume that the socket is client-side, and not
     # connected at the time of the call.  We connect it, then wrap it.
     if self._connected:
         raise ValueError("attempt to connect already-connected SSLSocket!")
     self._sslobj = self.context._wrap_socket(self, False, self.server_hostname)
     try:
         if connect_ex:
             rc = socket.connect_ex(self, addr)
         else:
             rc = None
             socket.connect(self, addr)
         if not rc:
             if self.do_handshake_on_connect:
                 self.do_handshake()
             self._connected = True
         return rc
     except socket_error:
         self._sslobj = None
         raise
Exemplo n.º 5
0
 def connect(self, *args):
     socket.connect(self, *args)
     self.do_handshake()
Exemplo n.º 6
0
 def connect(self, *args):
     socket.connect(self, *args)
     self.do_handshake()