-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
Summary
On JRuby 10.0.2.0 + Java 21, establishing an IMAPS connection using net-imap 0.5.12 crashes with:
java.lang.NullPointerException: Cannot invoke "org.jruby.ext.openssl.SSLContext$InternalContext.getSSLContext()" because "this.internalContext" is null
The exception occurs in org/jruby/ext/openssl/SSLContext.java:784 during createSSLEngine, called via SSLSocket#connect_nonblock.
This works on MRI Ruby (same host/service), and also works on JRuby with older net-imap versions (0.3.x).
Environment
- OS: Windows (mswin32)
- JRuby:
jruby 10.0.2.0 (3.4.2) 2025-08-07 cba6031bd0 OpenJDK 64-Bit Server VM 21.0.7+6-LTS on 21.0.7+6-LTS +indy +jit [x86_64-mswin32] - Java: OpenJDK 21.0.7+6-LTS
- net-imap: 0.5.12
- jruby-openssl: 0.15.5-java (also reproduced with 0.15.3-java)
- Target: outlook.office365.com:993 (IMAPS)
Reproduction
Gemfile
source "https://rubygems.org"
platform :jruby do
gem "net-imap", "0.5.12"
endScript
gem "net-imap", "0.5.12"
require "net/imap"
require "openssl"
imap = Net::IMAP.new("outlook.office365.com", 993, true, nil, false)
# or more modern
# imap = Net::IMAP.new("outlook.office365.com", port: 993, ssl: true)
puts imap.capability
imap.logout
imap.disconnectActual result
Unhandled Java exception:
Unhandled Java exception: java.lang.NullPointerException: Cannot invoke
"org.jruby.ext.openssl.SSLContext$InternalContext.getSSLContext()"
because "this.internalContext" is null
createSSLEngine at org/jruby/ext/openssl/SSLContext.java:784
...
Expected result
IMAPS connection should succeed or raise a Ruby-level exception, not crash with a JVM-level NPE.
Notes
- Connectivity verified with:
openssl s_client -connect outlook.office365.com:993 -crlf - JRuby 9.4.7.0 works with net-imap 0.3.x against the same server, but fails with net-imap 0.5.x (NPE).
- This appears to be an initialization/ordering bug where SSLContext.internalContext is not set before SSLSocket creates an SSLEngine.
Metadata
Metadata
Assignees
Labels
No labels