Sha256: 494707a9fb97079254334f8919b021418a074ec30b8b138bd712e3c953c800b5

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

require_relative '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

1 entries across 1 versions & 1 rubygems

Version Path
polarssl-0.0.2 test/ssl_connection_test.rb