Skip to content

Instantly share code, notes, and snippets.

@eoftedal
Created February 3, 2012 08:22
Show Gist options
  • Save eoftedal/1728927 to your computer and use it in GitHub Desktop.
Save eoftedal/1728927 to your computer and use it in GitHub Desktop.
Test tool needs to support Self-signed cert for non-prod environments. But the first request is horribly slow... (15 seconds) Does not happen in curl or wget
def preflight(uri)
#For some reason this speeds up connect on windows
require 'socket'
context = OpenSSL::SSL::SSLContext.new
tcp_client = TCPSocket.new uri.host, uri.port
ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, context
ssl_client.connect
end
preflight(uri)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl =(uri.scheme == 'https')
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = http.post(uri.path, data, headers)
@eoftedal
Copy link
Author

eoftedal commented Feb 3, 2012

Actually it's not related to self-signed at all, just https

@eoftedal
Copy link
Author

eoftedal commented Feb 3, 2012

preflight works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment