From baa7095f89e83571f53d6211a66f8272a20d6dbb Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 17 Jul 2024 15:10:14 +0000 Subject: [PATCH] Set imap/smtp APLN in autotest --- validation/autotest.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/validation/autotest.py b/validation/autotest.py index 8c2277f..b6c81a7 100755 --- a/validation/autotest.py +++ b/validation/autotest.py @@ -19,10 +19,13 @@ def test_smtp(server: dict): host = server["hostname"] port = server["port"] if server["socket"] == "SSL": - smtplib.SMTP_SSL(host, port) + context = ssl.create_default_context() + context.set_alpn_protocols("smtp") + smtplib.SMTP_SSL(host, port, context=context) elif server["socket"] == "STARTTLS": - smtpconn = smtplib.SMTP(host, port) + smtpconn = smtplib.SMTP(host, port, context=context) context = ssl.create_default_context() + context.set_alpn_protocols("smtp") smtpconn.starttls(context=context) smtpconn.ehlo() elif server["socket"] == "PLAIN": @@ -38,10 +41,13 @@ def test_imap(server: dict): host = server["hostname"] port = server["port"] if server["socket"] == "SSL": - imaplib.IMAP4_SSL(host, port=port) + context = ssl.create_default_context() + context.set_alpn_protocols("imap") + imaplib.IMAP4_SSL(host, port=port, context=context) elif server["socket"] == "STARTTLS": imapconn = imaplib.IMAP4(host, port=port) context = ssl.create_default_context() + context.set_alpn_protocols("imap") imapconn.starttls(ssl_context=context) elif server["socket"] == "PLAIN": imaplib.IMAP4(host, port)