Skip to content

Instantly share code, notes, and snippets.

@luikore
Created March 25, 2011 05:22
Show Gist options
  • Save luikore/886402 to your computer and use it in GitHub Desktop.
Save luikore/886402 to your computer and use it in GitHub Desktop.
inspect http connect request
require "eventmachine"
module SSLHandler
# an SSLHandler is created for every request
def initialize
@state = :head
end
def receive_data data
case @state
when :head
send_data "HTTP/1.1 200 OK\r\nProxy-Agent: RP\r\n\r\n"
puts 'starting tls'
# certs - http://www.akadia.com/services/ssh_test_certificate.html
# should add server.crt to browser certs
start_tls\
private_key_file: "#{File.dirname(__FILE__)}/server.key",
cert_chain_file: "#{File.dirname(__FILE__)}/server.crt",
verify_peer: false
@state = :body
else
print data
end
end
end
EM.run do
EM.start_server 'localhost', 8000, SSLHandler
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment