Repository navigation
Send close_notify when closing an SSL connection on JRuby - #4029
Merged
Merged
Conversation
MiniSSL::Engine#shutdown never called closeOutbound on an open connection, so MiniSSL::Socket#close had no close_notify alert to send and the socket closed without one. jruby-openssl 0.19.2 now rejects a TLS stream that ends that way, which broke pumactl's SSL stop command (test_control_ssl_ipv4/_ipv6).
joshuay03
force-pushed
the
jruby-ssl-close-notify
branch
from
September 28, 2026 09:13
f510eff to
1fc38d8
Compare
lewispb
added a commit
to basecamp/puma
that referenced
this pull request
Sep 28, 2026
…view * puma-upstream/main: Run Ragel generation check on Ubuntu only (puma#4030) Fix wakeup deadlock (puma#4025) Send close_notify when closing an SSL connection on JRuby (puma#4029) Separate unit and integration test commands (puma#3989) Fix NoMethodError when a malformed request has no request line (puma#3992)
4 of 7 tasks
nateberkopec
pushed a commit
to nateberkopec/puma
that referenced
this pull request
Nov 8, 2026
Co-authored-by: Joshua Young <[email protected]> (cherry picked from commit 3e98761)
nateberkopec
added a commit
that referenced
this pull request
Nov 9, 2026
* Fix flaky TestOutOfBandServer#test_stream Each app call waited on @app_finished with a 1s timeout. When the server accepted connections slower than the app threads drained them, a waiting thread timed out, both threads went idle, and the out-of-band hook fired mid-stream, so @oob_count ended up 2. Wait until the next request arrives or the test releases the app instead of timing out. On JRuby this failed 29 of 51 runs; it now passes 150 of 150. AI-assisted: claude-opus-5-5; thinking high (cherry picked from commit e789c8c) * Regenerate expired chain cert and fix its expiry check (#4039) The chain cert generator didn't set a validity period on the leaf cert, so it expired after the library's one year default while the CAs last four. The expiry test also compared against 30 days ago instead of 30 days from now, so it only failed a month after a cert expired. (cherry picked from commit 36b6033) * ci: test_error_logger.rb - fix TruffleRuby error (#3930) (cherry picked from commit 97996aa) * ci: test_puma_server_ssl.rb - fix two cipher suite tests (#3878) (cherry picked from commit 604be67) * ci: remove client `ctx.ssl_version` code from tests (#3981) (cherry picked from commit e451ff9) * Send close_notify when closing an SSL connection on JRuby (#4029) Co-authored-by: Joshua Young <[email protected]> (cherry picked from commit 3e98761) * ci: integration.rb - fixup restart_does_not_drop_connections in single mode (#3955) Fixes recent errors like: ``` 1) Failure: TestIntegrationSingle#test_hot_restart_does_not_drop_connections_threads [test/helpers/integration.rb:636]: 0 unexpected_response 0 refused 0 read timeout 0 reset 0 write_errors 1000 success 220 success after restart 1 restart count . Expected 1 to be >= 2. Fixes recent errors like: 1) Failure: TestIntegrationSingle#test_hot_restart_does_not_drop_connections_threads [test/helpers/integration.rb:636]: 0 unexpected_response 0 refused 0 read timeout 0 reset 0 write_errors 1000 success 220 success after restart 1 restart count Expected 1 to be >= 2. ``` Only changes behavior with 'single' runs. (cherry picked from commit dc972ef) * Run Ragel generation check on Ubuntu only (#4030) (cherry picked from commit d2aa78a) * Increase timeout for Intel JRuby tests to 12 minutes (#3876) Intel macOS runners are slower than ARM, causing test timeouts at 8 minutes. Recent failures show tests hitting timeouts and retries before the overall action timeout is reached. Co-authored-by: Claude Sonnet 4.5 <[email protected]> (cherry picked from commit fde728e) AI-assisted: claude-opus-5-5; thinking high * ci: drop retired macos-14 runners GitHub retired the macos-14 runner image on 2026-11-02, so every macos-14 job is now cancelled before it starts. Remove macos-14 from the test matrix and move the arm64 macOS JRuby job to macos-26. AI-assisted: claude-opus-5-5; thinking high * Fix -Wshorten-64-to-32 errors on Windows arm64 Ruby head (#4071) Ruby head now defines rb_len_t as a 64-bit type on Windows, where long is 32 bits. Cast the string length explicitly, and convert the size_t nread values with SIZET2NUM. AI-assisted: claude-opus-5-5; thinking high --------- Co-authored-by: Joshua Young <[email protected]> Co-authored-by: MSP-Greg <[email protected]> Co-authored-by: Islam Elsayed <[email protected]> Co-authored-by: Claude Sonnet 4.5 <[email protected]>
nateberkopec
added a commit
to nateberkopec/puma
that referenced
this pull request
Nov 11, 2026
Co-authored-by: Joshua Young <[email protected]> (cherry picked from commit 3e98761) AI-assisted: claude-opus-5-5
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Since 09-27 the four JRuby jobs on
mainfailTestPumaControlCli#test_control_ssl_ipv4and_ipv6, with pumactl printingclosing inbound before receiving peer's close_notifyin place ofCommand stop sent success. The last green run, on 09-16, used JRuby 10.1.1 with jruby-openssl 0.19.1. The first red run used JRuby 10.1.2 with jruby-openssl 0.19.2, whose release notes include "reject unexpected TLS EOFs unlessOP_IGNORE_UNEXPECTED_EOFis enabled". The only puma commit in between, #4027, touchesmini_ssl.c, which JRuby doesn't use.The client is right to complain: on JRuby, puma closes an SSL connection without sending
close_notify.MiniSSL::Socket#closecalls@engine.shutdownand, when it returns false, sends whatever@engine.extracthands back. The C engine'sSSL_shutdownqueues the alert, but the Javashutdownnever calledcloseOutbound()on an open connection, so there was nothing to extract. It only called it in the branch where outbound was already done, where it does nothing.This makes the Java
shutdownbehave like the C one:closeOutbound()and wrap once, so the alert is waiting for#extract.SSL_in_initcheck. Without this,test_http_rejectionfails, because a plain-HTTP client would get TLS alert bytes instead of EOF.MRI is unaffected; the change is Java only.
Testing
Locally on JRuby 10.1.2 with Temurin 21.0.12 and jruby-openssl 0.19.2, the same versions CI uses:
test/test_pumactl.rb -n /control_ssl/: 2 failures onmain, passing with this change.test_puma_server_ssl.rb(23 runs),test_pumactl.rb,test_minissl.rbandtest_integration_ssl.rball pass.test_integration_pumactl.rb's*_unixtests fail on my machine with and without this change, so they are local and unrelated.This should also clear the red JRuby jobs on open PRs, including #4028.
Your checklist for this pull request
test_control_ssl_*tests are the regression tests;test_http_rejectioncovers the handshake guard.)[ci skip]to the title of the PR.#issue" to the PR description or my commit messages.I use AI assistance when working on patches, and I check and test everything before submitting.