Skip to content

Instantly share code, notes, and snippets.

@dv
Created April 20, 2014 14:41
Show Gist options
  • Save dv/11115764 to your computer and use it in GitHub Desktop.
Save dv/11115764 to your computer and use it in GitHub Desktop.
require 'socket'
require 'openssl'
tcp_client = TCPSocket.new "google.com", 443
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client
ssl_client.hostname = "google.com" # SNI, if not it returns the first SSL cert for this IP instead of hostname
ssl_client.connect
# Work
ssl_client.sysclose
tcp_client.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment