Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
JRuby/Java SSL issue
% jruby ssl-test.rb # not the actual command, I ran with our internal hostname in the source as with others
OpenSSL::SSL::SSLError: certificate verify failed
connect at org/jruby/ext/openssl/
connect at /opt/rubies/jruby-
timeout at org/jruby/ext/timeout/
connect at /opt/rubies/jruby-
do_start at /opt/rubies/jruby-
start at /opt/rubies/jruby-
(root) at ssl-test.rb:8
#! /usr/bin/env ruby
require 'net/https'
require 'uri'
uri = URI.parse(ARGV[0] || '')
http =, uri.port)
http.use_ssl = true
http.start {
http.request_get(uri.path) {|res|
print res.body
% java SSLPoke 443
Successfully connected
# from:
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
public class SSLPoke {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Usage: "+SSLPoke.class.getName()+" <host> <port>");
try {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(args[0], Integer.parseInt(args[1]));
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
// Write a test byte to get a reaction :)
while (in.available() > 0) {
System.out.println("Successfully connected");
} catch (Exception exception) {
tvon@foo % java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
tvon@foo % jruby -version
jruby (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_25-b17 +jit [darwin-x86_64]
NameError: undefined local variable or method `rsion' for main:Object
(root) at -e:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment