Sha256: 37222bcf1a81fcfee6045cd65e2fced617a45d37770dbdebbc765285be550b1e

Contents?: true

Size: 707 Bytes

Versions: 7

Compression:

Stored size: 707 Bytes

Contents

require 'test_helper'
require 'socket'

class SSLConnectionTest < MiniTest::Unit::TestCase

  def test_simple_connection

    socket = TCPSocket.new('polarssl.org', 443)

    entropy = PolarSSL::Entropy.new

    ctr_drbg = PolarSSL::CtrDrbg.new(entropy)

    ssl = PolarSSL::SSL.new

    ssl.set_endpoint(PolarSSL::SSL::SSL_IS_CLIENT)
    ssl.set_authmode(PolarSSL::SSL::SSL_VERIFY_NONE)
    ssl.set_rng(ctr_drbg)

    ssl.set_socket(socket)

    ssl.handshake

    ssl.write("GET / HTTP/1.0\r\nHost: polarssl.org\r\n\r\n")

    response = ""

    while chunk = ssl.read(1024)
      response << chunk
    end

    assert response.length > 0

    ssl.close_notify

    socket.close

    ssl.close
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
polarssl-1.0.2 test/ssl_connection_test.rb
polarssl-1.0.1 test/ssl_connection_test.rb
polarssl-1.0.0 test/ssl_connection_test.rb
polarssl-0.0.7 test/ssl_connection_test.rb
polarssl-0.0.6 test/ssl_connection_test.rb
polarssl-0.0.5 test/ssl_connection_test.rb
polarssl-0.0.3 test/ssl_connection_test.rb