I had to hack the bundler executable to load the jruby-openssl gem before it tried to load bundler. Then it worked.

I think the gem command uses openssl, which is built into the MRI version of Ruby, but has to be included as a gem by JRuby and therefore it happens too late.