Skip to content

Instantly share code, notes, and snippets.

@advorak
Forked from anonymous/gist:d230ca7e84c1293b9dab
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save advorak/ec229c08750cc4ca660f to your computer and use it in GitHub Desktop.
Save advorak/ec229c08750cc4ca660f to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# http://stackoverflow.com/questions/12836847/how-to-establish-a-ssl-enabled-tcp-ip-connection-in-ruby
require 'socket'
require 'openssl'
socket = TCPSocket.open('crew-access-data.ual.com', 34135)
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
ssl_socket.sync_close = true
ssl_socket.connect
# The above connect command produces the following:
#OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert handshake failure
# from (irb):12:in `connect'
# from (irb):12
# from /home/advorak/.rbenv/versions/2.1.2/bin/irb:11:in `<main>'
#.....
while line = ssl_socket.gets
p line
end
ssl_socket.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment