Class: HTTPAccess2::SSLSocketWrap

Inherits:
Object
  • Object
show all
Defined in:
lib/reap/vendor/http-access2.rb

Overview

HTTPAccess2::SSLSocketWrap

Instance Method Summary collapse

Constructor Details

#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap

Returns a new instance of SSLSocketWrap.



991
992
993
994
995
996
997
998
999
1000
# File 'lib/reap/vendor/http-access2.rb', line 991

def initialize(socket, context, debug_dev = nil)
  unless SSLEnabled
    raise RuntimeError.new(
      "Ruby/OpenSSL module is required for https access.")
  end
  @context = context
  @socket = socket
  @ssl_socket = create_ssl_socket(@socket)
  @debug_dev = debug_dev
end

Instance Method Details

#<<(str) ⇒ Object



1054
1055
1056
1057
1058
# File 'lib/reap/vendor/http-access2.rb', line 1054

def <<(str)
  rv = @ssl_socket.write(str)
  @debug_dev << str if @debug_dev
  rv
end

#addrObject



1025
1026
1027
# File 'lib/reap/vendor/http-access2.rb', line 1025

def addr
  @socket.addr
end

#closeObject



1029
1030
1031
1032
# File 'lib/reap/vendor/http-access2.rb', line 1029

def close
  @ssl_socket.close
  @socket.close
end

#closed?Boolean

Returns:

  • (Boolean)


1034
1035
1036
# File 'lib/reap/vendor/http-access2.rb', line 1034

def closed?
  @socket.closed?
end

#eof?Boolean

Returns:

  • (Boolean)


1038
1039
1040
# File 'lib/reap/vendor/http-access2.rb', line 1038

def eof?
  @ssl_socket.eof?
end

#flushObject



1060
1061
1062
# File 'lib/reap/vendor/http-access2.rb', line 1060

def flush
  @ssl_socket.flush
end

#gets(*args) ⇒ Object



1042
1043
1044
1045
1046
# File 'lib/reap/vendor/http-access2.rb', line 1042

def gets(*args)
  str = @ssl_socket.gets(*args)
  @debug_dev << str if @debug_dev
  str
end

#peer_certObject



1021
1022
1023
# File 'lib/reap/vendor/http-access2.rb', line 1021

def peer_cert
  @ssl_socket.peer_cert
end

#post_connection_check(host) ⇒ Object



1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/reap/vendor/http-access2.rb', line 1006

def post_connection_check(host)
  verify_mode = @context.verify_mode || OpenSSL::SSL::VERIFY_NONE
  if verify_mode == OpenSSL::SSL::VERIFY_NONE
    return
  elsif @ssl_socket.peer_cert.nil? and
      check_mask(verify_mode, OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT)
    raise OpenSSL::SSL::SSLError, "no peer cert"
  end
  hostname = host.host
  if @ssl_socket.respond_to?(:post_connection_check)
    @ssl_socket.post_connection_check(hostname)
  end
  @context.post_connection_check(@ssl_socket.peer_cert, hostname)
end

#read(*args) ⇒ Object



1048
1049
1050
1051
1052
# File 'lib/reap/vendor/http-access2.rb', line 1048

def read(*args)
  str = @ssl_socket.read(*args)
  @debug_dev << str if @debug_dev
  str
end

#ssl_connectObject



1002
1003
1004
# File 'lib/reap/vendor/http-access2.rb', line 1002

def ssl_connect
  @ssl_socket.connect
end

#syncObject



1064
1065
1066
# File 'lib/reap/vendor/http-access2.rb', line 1064

def sync
  @ssl_socket.sync
end

#sync=(sync) ⇒ Object



1068
1069
1070
# File 'lib/reap/vendor/http-access2.rb', line 1068

def sync=(sync)
  @ssl_socket.sync = sync
end