Skip to content

Add default certificate store when none given #1089

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/mail/network/delivery_methods/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ def ssl_context
openssl_verify_mode = "OpenSSL::SSL::VERIFY_#{openssl_verify_mode.upcase}".constantize
end

context = Net::SMTP.default_ssl_context
context.verify_mode = openssl_verify_mode if openssl_verify_mode
context.ca_path = settings[:ca_path] if settings[:ca_path]
context.ca_file = settings[:ca_file] if settings[:ca_file]
context
Net::SMTP.default_ssl_context.tap do |context|
context.verify_mode = openssl_verify_mode if openssl_verify_mode

if settings[:ca_path] || settings[:ca_file]
context.ca_path = settings[:ca_path] if settings[:ca_path]
context.ca_file = settings[:ca_file] if settings[:ca_file]
elsif openssl_verify_mode && openssl_verify_mode != OpenSSL::SSL::VERIFY_NONE
context.cert_store = OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we always set the cert store? Does it need to be mutually exclusive with provided CA path/file settings?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Unfortunately I'm not sure myself. I based this off #set_params which checks all three settings (including cert_store itself).

end
end
end
end