Skip to content

Instantly share code, notes, and snippets.

@bryanbibat
Created February 8, 2011 07:37
Show Gist options
  • Save bryanbibat/816046 to your computer and use it in GitHub Desktop.
Save bryanbibat/816046 to your computer and use it in GitHub Desktop.
openssl req -new -sha1 -newkey rsa:1024 -nodes -keyout client.key -out request.pem
mkdir -p demoCA/newcerts
touch demoCA/index.txt
touch demoCA/index.txt.attr
vim demoCA/serial
sudo openssl ca -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -keyfile /etc/ssl/private/ssl-cert-snakeoil.key -policy policy_anything -out signed.pem -infiles request.pem
sudo openssl pkcs12 -export -in signed.pem -inkey client.key -certfile /etc/ssl/certs/ssl-cert-snakeoil.pem -name "testp12" -out test-p12.p12
require "net/https"
require "uri"
uri = URI.parse("https://localhost/")
pem = File.read("/home/pc3/signed.pem")
key = File.read("/home/pc3/client.key")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(pem)
http.key = OpenSSL::PKey::RSA.new(key)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment