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
Support starttls connections #1084
Conversation
Provide ability to serve "starttls_options", if set ssl will be disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition. Needs test coverage!
|
||
imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false) | ||
tmp_ssl = settings[:enable_ssl] | ||
tmp_ssl = false unless settings[:starttls_options].nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these options are mutually exclusive, we can raise an ArgumentError if both are set.
tmp_ssl = false unless settings[:starttls_options].nil? | ||
|
||
imap = Net::IMAP.new(settings[:address], settings[:port], tmp_ssl, nil, false) | ||
if settings[:starttls_options].is_a?(Hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Providing an options hash to enable/disable the feature is a bit awkward, particular if you don't need to set any options. Would expose this as a boolean: starttls: true
|
||
imap = Net::IMAP.new(settings[:address], settings[:port], tmp_ssl, nil, false) | ||
if settings[:starttls_options].is_a?(Hash) | ||
imap.starttls(settings[:starttls_options]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options aren't unique to STARTTLS. They're also used when SSL is enabled. Both establish a TLS session on the socket.
That suggests calling this tls_options: { … }
and allowing it to be used in conjunction with both IMAPS and STARTTLS.
Provide ability to serve "starttls_options", if set ssl will be disabled.