Project

General

Profile

Bug #9822 ยป ssl_example.rb

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

 
1
require 'openssl'
2
require 'socket'
3

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

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

    
14
request = <<-EOR
15
GET / HTTP/1.1
16
Host: ssl-gost.envek.name
17
Connection: close
18

    
19
EOR
20
# Don't remove blank line above!
21

    
22
ssl_socket.puts(request)
23
puts ssl_socket.read
24
ssl_socket.close