Skip to content
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

Net::SMTP.start() and #start() accepts ssl_context_params keyword argument #22

Merged
merged 2 commits into from
Mar 14, 2021
Merged

Net::SMTP.start() and #start() accepts ssl_context_params keyword argument #22

merged 2 commits into from
Mar 14, 2021

Conversation

TomFreudenberg
Copy link
Contributor

This PR comes as a replacement of PR #17

Additional params are passed to OpenSSL::SSL::SSLContext#set_params.

For example, Net::SMTP#start(ssl_context_params: { cert_store: my_store, timeout: 123 })
calls set_params({ cert_store: my_store, timeout: 123 }).




In PR #17 additional any tls_ prefixed additional keyword arguments are magically renamed and passed to OpenSSL::SSL::SSLContext#set_params.

This may conflict in namings like tls_cert_store is not as clear as ssl_context_params: { cert_store: my_store }

No magic in between anymore

Also this makes it easier to allow forwarding this params in additional components like Mikel/mail




As an example => create your own store and forward a self signed in memory CERT

smtp = Net::SMTP.new('127.0.0.1', 5555)
smtp.enable_starttls if tls_enabled

cert_store = OpenSSL::X509::Store.new
cert_store.add_cert(self_signed.cert)

smtp.start('localhost', auth_id, password, auth_type, ssl_context_params: { cert_store: cert_store, verify_mode: OpenSSL::SSL::VERIFY_PEER }) do
   smtp.send_message(message_data + "\r\n", envelope_mail_from, envelope_rcpt_to)
end

…ument

	Additional params are passed to OpenSSL::SSL::SSLContext#set_params.

	For example, `Net::SMTP#start(ssl_context_params: { cert_store: my_store, timeout: 123 })`
	calls `set_params({ cert_store: my_store, timeout: 123 })`.
@TomFreudenberg
Copy link
Contributor Author

I am the maintainer of Midi-Smtp-Server gem and worked on the compatibility for this gem on Ruby 2.6, 2.7 and 3.0

While Ruby 2.6 and 2.7 are still running all my tests the MidiSmtpServer tests fail on Ruby 3.0. (raised: "self signed certificate")

As identified, net-smtp starting with commit d6b9ad8 causes the problems.

In case that I won't just disable the tls_verify: false I tried to figure out how to enable tests also with self signed certificates.

In result this PR comes up - hope you like it and it will pass.

For any additional work, please give me a note.

Cheers
Tom

@TomFreudenberg
Copy link
Contributor Author

Hi @hsbt @tmtm @nobu

I am not sure to whom this PR align - please let me know if anything else can be done from my side.

It would be very nice to get some feedback - I will try to follow up with a corresponding patch to Mikel/Mail as well.

Thanks for your work and support
Tom

@tmtm tmtm merged commit dbaf506 into ruby:master Mar 14, 2021
@TomFreudenberg
Copy link
Contributor Author

Hi Tomita @tmtm

thanks for already merging that PR!

Do you have any scheduling when a next net-smtp gem release will be published?

I am just asking in case of coordinating other gem updates with that feature.

Thanks again and in advance for a short note.

Cheers
Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants