🔒 Add ssl_ctx
and ssl_ctx_params
attr readers
#174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Net::IMAP#ssl_ctx
will return theOpenSSL::SSL::SSLContext
used by theOpenSSL::SSL::SSLSocket
when TLS is attempted, even when the TLS handshake is unsuccessful. The context object will be frozen. It will returnnil
for a plaintext connection.Net::IMAP#ssl_ctx_params
will return the parameters that were sent toOpenSSL::SSL::SSLContext#set_params
when the connection tries to use TLS (even when unsuccessful). It will returnfalse
for a plaintext connection.Additionally, error handling for the arguments to
#starttls
was moved before sending the command to the server. This way a simple argument error will still raise an exception, but won't result in dropping the connection. Becausessl_ctx
is also created ahead of time, this will also catch invalid SSLContext params.Tangentially:
#initialize
was moved to the top of thepublic
section of the class definition, to match common conventions.#initialize
and#startls
rdoc, including examples, links toOpenSSL::SSL::SSLContext#set_params
, etc.#initialize
was refactored into several extracted private methods, for readability.