| 29 | remotePort = 587 |
| 30 | |
| 31 | def test_connect_starttls(self): |
| 32 | support.get_attribute(smtplib, 'SMTP_SSL') |
| 33 | context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 34 | context.check_hostname = False |
| 35 | context.verify_mode = ssl.CERT_NONE |
| 36 | with socket_helper.transient_internet(self.testServer): |
| 37 | server = smtplib.SMTP(self.testServer, self.remotePort) |
| 38 | try: |
| 39 | server.starttls(context=context) |
| 40 | except smtplib.SMTPException as e: |
| 41 | if e.args[0] == 'STARTTLS extension not supported by server.': |
| 42 | unittest.skip(e.args[0]) |
| 43 | else: |
| 44 | raise |
| 45 | server.ehlo() |
| 46 | server.quit() |
| 47 | |
| 48 | |
| 49 | class SmtpSSLTest(unittest.TestCase): |