Project

General

Profile

Bug #9822 » ssl_example.rb

Test script - Envek (Andrey Novikov), 05/09/2014 08:21 PM

 
require 'openssl'
require 'socket'

OpenSSL::Engine.load
gost_engine = OpenSSL::Engine.by_id('gost')
gost_engine.set_default(0xFFFF) # It's required, but I don't know why

socket = TCPSocket.open('ssl-gost.envek.name', 443)
ssl_context = OpenSSL::SSL::SSLContext.new()
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
ssl_socket.sync_close = true
ssl_socket.connect

request = <<-EOR
GET / HTTP/1.1
Host: ssl-gost.envek.name
Connection: close

EOR
# Don't remove blank line above!

ssl_socket.puts(request)
puts ssl_socket.read
ssl_socket.close
(2-2/2)