-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
smtplib should support SSL contexts #53055
Comments
3.2 introduces SSL contexts, which allow bundling SSL configuration options, certificates and private keys into a single (potentially long-lived) structure. The SMTP_SSL constructor should allow passing an SSL context object instead of a key/cert pair. |
Is anybody working on this issue? If not, I think it looks like it might be a nice one for me to tackle. I'll go ahead unless there are any objections. |
Nobody is working on it AFAIK. Feel free to give it a try :) |
I did a patch that allows smtplib.SMTP_SSL constructor to accept an optional SSLContext |
This sentence is awkward, at best. I suggest something like: "SSLcontext, also optional, is an alternative to keyfile and certfile; if it is specified, keyfile and certfile must be None." |
It should also explain how the context can be used. |
I'm submitting a new patch with changes suggested by Terry. But I feel an example of how to use a SSLContext inside the Docstring of SMTP_SSL constructor is unnecessary since no smtp specific things are done to the passed SSLContext. Any ideas about this suggestion? |
Thanks for the patch. A couple of comments:
I don't think an example of using a context is necessary. By using proper ReST markup a link will be generated to the SSLContext documentation, and that's probably enough for people to understand. |
I did another patch based on feedback given. A test for SMTP_SSL wasn't added; will look into it later. Tab character that were present are removed. Also SSLContext support was added to starttls() but it is slightly different from the starttls() implementation of imaplib. Further feedback would be much appreciated. |
For the record, bpo-11927 reminds me that test_smtpnet actually has a trivial test for SMTP-over-SSL. |
So, thanks for the new patch. I tested it with my ISP's server and it works fine! Two remaining issues though:
Thank you again. |
Thanks for the quick review. I'm submitting a new patch with changes suggested. |
Thank you, the patch looks good. A simple test could probably be added to test_smtpnet, along the lines of the existing tests, do you want to tackle that? |
Yes, I would like to have a try at it |
I added a test to smtpnet and submitting a separate patch for it as my test_smtpnet.py file was old and could have had conflicts. I didn't use keys and certificates for the SSLContext as those would have to be shipped with the source. Looking forward for reviews and suggestions. |
New changeset 6737de76487b by Antoine Pitrou in branch 'default': |
Thank you Kasun. I did a couple of minor style fixes (whitespace at end of line, and spaces around the '=' assignment sign). I also added a test for starttls(), since it turns out gmail.com supports it on port 25. |
Thanks Antoine |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: