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
minissl.c - Use Random.bytes if available #2642
Conversation
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.
Looks good!
I looked at this one more time, and thought maybe the below was a little clearer. Note that this code is only called on Puma start/restart, once for each ssl binder/listener. // Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
#ifdef HAVE_RANDOM_BYTES
bytes_func = rb_cRandom;
#else
bytes_func = rb_const_get(rb_cRandom, rb_intern_const("DEFAULT"));
#endif
session_id_bytes = rb_funcall(bytes_func, rb_intern_const("bytes"),
1, ULL2NUM(SSL_MAX_SSL_SESSION_ID_LENGTH)); If anyone has objections, please let me know, otherwise I'll change. I also added the comment to |
I like the approach, but I don't like the name // Random.bytes available in Ruby 2.5 and later, Random::DEFAULT deprecated in 3.0
session_id_bytes = rb_funcall(
#ifdef HAVE_RANDOM_BYTES
rb_cRandom,
#else
rb_const_get(rb_cRandom, rb_intern_const("DEFAULT")),
#endif
bytes_func,
rb_intern_const("bytes"),
1, ULL2NUM(SSL_MAX_SSL_SESSION_ID_LENGTH)
); |
Co-authored-by: Ekin Dursun <ekindursun@gmail.com>
* Actions - add Ruby 3.0 and 3.1 * .gitignore - add entry for local use * test_puma_server_ssl.rb - backport fix 888b0213f11 * minissl.c and extconf.rb - backport fixes Fixes from PR's: #2535 #2633 #2642
Co-authored-by: Ekin Dursun <ekindursun@gmail.com> Co-authored-by: Ekin Dursun <ekindursun@gmail.com>
Description
PR #2633 throws deprecation warnings in Ruby 3. Fix by using
Random.bytes
when available.Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.