Skip to content

Instantly share code, notes, and snippets.

@matthewlehner
Created May 15, 2015 15:43
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 matthewlehner/db6b5618efe84f2e42c8 to your computer and use it in GitHub Desktop.
Save matthewlehner/db6b5618efe84f2e42c8 to your computer and use it in GitHub Desktop.
SSL protocol check
require "net/http"
require "openssl"
uri = URI("https://github.com")
request = Net::HTTP.new(uri, 443)
request.use_ssl = true
request.ssl_version = :SSLv23
request.verify_mode = OpenSSL::SSL::VERIFY_NONE
request.get("/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request.ssl_version = :SSLv23
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
response.status
response["header-here"] # All headers are lowercase
# http://stackoverflow.com/questions/12836847/how-to-establish-a-ssl-enabled-tcp-ip-connection-in-ruby
require 'socket'
require 'openssl'
require 'uri'
OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers] = "SSLv23:!aNULL:!eNULL:!SSLv3:!TLSv1:!TLSv1_1:!TLSv1_2"
uri = URI.parse("https://www.scripps.org/")
socket = TCPSocket.open(uri.host, uri.port)
ctx = OpenSSL::SSL::SSLContext.new()
ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_NONE)
ctx.ssl_version = :SSLv23
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
ssl_socket.sync_close = true
ssl_socket.connect
puts ssl_socket.ssl_version
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