Ejemplo n.º 1
0
 def _get_socket(self, host, port, timeout):
     if self.debuglevel > 0:
         print >> sys.stderr, 'connect:', (host, port)
     new_socket = socket.create_connection((host, port), timeout)
     new_socket = sslutil.ssl_wrap_socket(new_socket,
                                          self.keyfile, self.certfile,
                                          **self._sslkwargs)
     self.file = smtplib.SSLFakeFile(new_socket)
     return new_socket
Ejemplo n.º 2
0
 def connect(self):
     if has_https and self.realhostport: # use CONNECT proxy
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.sock.connect((self.host, self.port))
         if _generic_proxytunnel(self):
             # we do not support client X.509 certificates
             self.sock = sslutil.ssl_wrap_socket(self.sock, None, None)
     else:
         keepalive.HTTPConnection.connect(self)
Ejemplo n.º 3
0
 def _get_socket(self, host, port, timeout):
     if self.debuglevel > 0:
         print >> sys.stderr, 'connect:', (host, port)
     new_socket = socket.create_connection((host, port), timeout)
     new_socket = sslutil.ssl_wrap_socket(new_socket, self.keyfile,
                                          self.certfile,
                                          **self._sslkwargs)
     self.file = smtplib.SSLFakeFile(new_socket)
     return new_socket
Ejemplo n.º 4
0
 def connect(self):
     if has_https and self.realhostport:  # use CONNECT proxy
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.sock.connect((self.host, self.port))
         if _generic_proxytunnel(self):
             # we do not support client X.509 certificates
             self.sock = sslutil.ssl_wrap_socket(self.sock, None, None)
     else:
         keepalive.HTTPConnection.connect(self)
Ejemplo n.º 5
0
        def connect(self):
            self.sock = _create_connection((self.host, self.port))

            host = self.host
            if self.realhostport: # use CONNECT proxy
                _generic_proxytunnel(self)
                host = self.realhostport.rsplit(':', 1)[0]
            self.sock = sslutil.ssl_wrap_socket(
                self.sock, self.key_file, self.cert_file,
                **sslutil.sslkwargs(self.ui, host))
            sslutil.validator(self.ui, host)(self.sock)
Ejemplo n.º 6
0
        def connect(self):
            self.sock = _create_connection((self.host, self.port))

            host = self.host
            if self.realhostport:  # use CONNECT proxy
                _generic_proxytunnel(self)
                host = self.realhostport.rsplit(':', 1)[0]
            self.sock = sslutil.ssl_wrap_socket(
                self.sock, self.key_file, self.cert_file,
                **sslutil.sslkwargs(self.ui, host))
            sslutil.validator(self.ui, host)(self.sock)
Ejemplo n.º 7
0
 def starttls(self, keyfile=None, certfile=None):
     if not self.has_extn("starttls"):
         msg = "STARTTLS extension not supported by server"
         raise smtplib.SMTPException(msg)
     (resp, reply) = self.docmd("STARTTLS")
     if resp == 220:
         self.sock = sslutil.ssl_wrap_socket(self.sock, keyfile, certfile,
                                             **self._sslkwargs)
         if not util.safehasattr(self.sock, "read"):
             # using httplib.FakeSocket with Python 2.5.x or earlier
             self.sock.read = self.sock.recv
         self.file = smtplib.SSLFakeFile(self.sock)
         self.helo_resp = None
         self.ehlo_resp = None
         self.esmtp_features = {}
         self.does_esmtp = 0
     return (resp, reply)
Ejemplo n.º 8
0
 def starttls(self, keyfile=None, certfile=None):
     if not self.has_extn("starttls"):
         msg = "STARTTLS extension not supported by server"
         raise smtplib.SMTPException(msg)
     (resp, reply) = self.docmd("STARTTLS")
     if resp == 220:
         self.sock = sslutil.ssl_wrap_socket(self.sock, keyfile, certfile,
                                             **self._sslkwargs)
         if not util.safehasattr(self.sock, "read"):
             # using httplib.FakeSocket with Python 2.5.x or earlier
             self.sock.read = self.sock.recv
         self.file = smtplib.SSLFakeFile(self.sock)
         self.helo_resp = None
         self.ehlo_resp = None
         self.esmtp_features = {}
         self.does_esmtp = 0
     return (resp, reply)