Skip to content

Instantly share code, notes, and snippets.

@hukl
Created August 21, 2010 18:02
Show Gist options
  • Select an option

  • Save hukl/542647 to your computer and use it in GitHub Desktop.

Select an option

Save hukl/542647 to your computer and use it in GitHub Desktop.
require 'openssl'
require 'socket'
header = <<HEADER
GET / HTTP/1.1
Host: example.com
Origin: localhost
Content-Length: 0
Content-Type: text/plain
Connection: close\r\n\r\n
HEADER
begin
s = TCPSocket.open("example.com", 443)
ssl_context = OpenSSL::SSL::SSLContext.new
puts ssl_context.verify_mode
s = OpenSSL::SSL::SSLSocket.new( s, ssl_context )
s.sync_close = true
s.connect
s.post_connection_check("example.com")
s.write header
puts s.read
ensure
s.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment