Skip to content

Commit 73014d5

Browse files
gh-136134: Add code comment explaining CRAM-MD5 fallback and NEWS entry
1 parent b379ce4 commit 73014d5

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/smtplib.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,9 @@ def login(self, user, password, *, initial_response_ok=True):
744744
except SMTPAuthenticationError as e:
745745
last_exception = e
746746
except ValueError as e:
747+
# Some environments (e.g., FIPS) disable certain hashing algorithms like MD5,
748+
# which are required by CRAM-MD5. This raises a ValueError when trying to use HMAC.
749+
# If this happens, we catch the exception and continue trying the next auth method.
747750
last_exception = e
748751
if 'unsupported' in str(e).lower():
749752
continue
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make smtplib fallback to next auth method if CRAM-MD5 fails due to
2+
unsupported hash (e.g. FIPS). Contributed by Raphael Rodrigues.

0 commit comments

Comments
 (0)